From dddda495138060d60febe4cc15f03c3461b13e29 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 13 Feb 2010 13:46:34 +0200 Subject: [PATCH] imported winuaesrc2020b11.zip --- a2065.c => a2065.cpp | 4 +- a2091.c => a2091.cpp | 4 +- adide.c => adide.cpp | 0 akiko.c => akiko.cpp | 12 +- akiko2.c => akiko2.cpp | 0 amax.c => amax.cpp | 2 +- ar.c => ar.cpp | 8 +- arcadia.c => arcadia.cpp | 6 +- archivers/7z/{7zBuf.c => 7zBuf.cpp} | 0 archivers/7z/{7zCrc.c => 7zCrc.cpp} | 0 archivers/7z/{7zStream.c => 7zStream.cpp} | 0 .../7z/Archive/7z/{7zAlloc.c => 7zAlloc.cpp} | 0 .../Archive/7z/{7zDecode.c => 7zDecode.cpp} | 0 .../Archive/7z/{7zExtract.c => 7zExtract.cpp} | 0 .../Archive/7z/{7zHeader.c => 7zHeader.cpp} | 0 archivers/7z/Archive/7z/{7zIn.c => 7zIn.cpp} | 0 .../7z/Archive/7z/{7zItem.c => 7zItem.cpp} | 0 archivers/7z/{Bcj2.c => Bcj2.cpp} | 0 archivers/7z/{Bra.c => Bra.cpp} | 0 archivers/7z/{Bra86.c => Bra86.cpp} | 0 archivers/7z/{LzmaDec.c => LzmaDec.cpp} | 0 archivers/dms/{crc_csum.c => crc_csum.cpp} | 0 archivers/dms/{getbits.c => getbits.cpp} | 0 archivers/dms/{maketbl.c => maketbl.cpp} | 0 archivers/dms/{pfile.c => pfile.cpp} | 12 +- archivers/dms/{tables.c => tables.cpp} | 0 archivers/dms/{u_deep.c => u_deep.cpp} | 6 +- archivers/dms/{u_heavy.c => u_heavy.cpp} | 2 +- archivers/dms/{u_init.c => u_init.cpp} | 0 archivers/dms/{u_medium.c => u_medium.cpp} | 0 archivers/dms/{u_quick.c => u_quick.cpp} | 0 archivers/dms/{u_rle.c => u_rle.cpp} | 0 archivers/lha/{crcio.c => crcio.cpp} | 38 +- archivers/lha/{dhuf.c => dhuf.cpp} | 26 +- archivers/lha/{header.c => header.cpp} | 62 +- archivers/lha/{huf.c => huf.cpp} | 28 +- archivers/lha/{larc.c => larc.cpp} | 18 +- archivers/lha/lha.h | 24 +- .../lha/{lhamaketbl.c => lhamaketbl.cpp} | 7 +- archivers/lha/{lharc.c => lharc.cpp} | 41 +- archivers/lha/{shuf.c => shuf.cpp} | 28 +- archivers/lha/{slide.c => slide.cpp} | 4 +- archivers/lha/{uae_lha.c => uae_lha.cpp} | 3 +- archivers/lha/{util.c => util.cpp} | 13 +- archivers/lzx/{unlzx.c => unlzx.cpp} | 12 +- archivers/wrp/warp.c | 481 ----- archivers/wrp/warp.cpp | 481 +++++ archivers/xfd/{main.c => main.cpp} | 0 archivers/xfd/{xfd.c => xfd.cpp} | 0 archivers/zip/{unzip.c => unzip.cpp} | 125 +- audio.c => audio.cpp | 10 +- autoconf.c => autoconf.cpp | 2 +- blitops.c => blitops.cpp | 0 blitter.c => blitter.cpp | 2 +- blkdev.c => blkdev.cpp | 6 +- blkdev_cdimage.c => blkdev_cdimage.cpp | 6 +- bsdsocket.c => bsdsocket.cpp | 27 +- build68k.c => build68k.cpp | 0 catweasel.c => catweasel.cpp | 7 +- cd32_fmv.c => cd32_fmv.cpp | 2 +- cdrom.c => cdrom.cpp | 0 cdtv.c => cdtv.cpp | 0 cfgfile.c => cfgfile.cpp | 51 +- cia.c => cia.cpp | 2 +- consolehook.c => consolehook.cpp | 4 +- core.cw4.c => core.cw4.cpp | 0 cpummu.c => cpummu.cpp | 0 cpuopti.c => cpuopti.cpp | 0 crc32.c => crc32.cpp | 13 +- custom.c => custom.cpp | 36 +- debug.c => debug.cpp | 51 +- disk.c => disk.cpp | 56 +- diskutil.c => diskutil.cpp | 0 dongle.c => dongle.cpp | 0 drawing.c => drawing.cpp | 6 +- driveclick.c => driveclick.cpp | 6 +- enforcer.c => enforcer.cpp | 6 +- epsonprinter.c => epsonprinter.cpp | 9 +- ersatz.c => ersatz.cpp | 0 expansion.c => expansion.cpp | 2 +- fdi2raw.c => fdi2raw.cpp | 20 +- filesys.c => filesys.cpp | 294 +-- filesys_bootrom.c => filesys_bootrom.cpp | 0 fpp.c => fpp.cpp | 4 +- fsdb.c => fsdb.cpp | 22 +- fsdb_unix.c => fsdb_unix.cpp | 0 fsusage.c => fsusage.cpp | 2 +- gayle.c => gayle.cpp | 30 +- genblitter.c => genblitter.cpp | 0 gencpu.c => gencpu.cpp | 14 +- gencpu_mini.c => gencpu_mini.cpp | 0 gengenblitter.c => gengenblitter.cpp | 0 genlinetoscr.c => genlinetoscr.cpp | 29 +- genp2c.c => genp2c.cpp | 0 gfxlib.c => gfxlib.cpp | 0 gfxutil.c => gfxutil.cpp | 0 gtkui.c => gtkui.cpp | 0 hardfile.c => hardfile.cpp | 44 +- hrtmon.rom.c => hrtmon.rom.cpp | 0 identify.c => identify.cpp | 0 include/blkdev.h | 4 +- include/bsdsocket.h | 3 +- include/cpu_prefetch.h | 5 + include/debug.h | 6 +- include/disk.h | 2 +- include/driveclick.h | 8 +- include/filesys.h | 22 +- include/fsdb.h | 19 +- include/fsusage.h | 11 +- include/gfxfilter.h | 42 +- include/memory.h | 6 +- include/moduleripper.h | 5 +- include/newcpu.h | 9 +- include/options.h | 89 - include/readcpu.h | 6 +- include/sysdeps.h | 37 +- include/xwin.h | 1 + include/zarchive.h | 2 +- include/zfile.h | 36 +- inprec.c => inprec.cpp | 0 inputdevice.c => inputdevice.cpp | 14 +- jit/{codegen_x86.c => codegen_x86.cpp} | 0 jit/{compemu_fpp.c => compemu_fpp.cpp} | 0 ...imizer_x86.c => compemu_optimizer_x86.cpp} | 0 ...{compemu_raw_x86.c => compemu_raw_x86.cpp} | 10 +- ...{compemu_support.c => compemu_support.cpp} | 36 +- ..._codegen.c => compemu_support_codegen.cpp} | 0 jit/{gencomp.c => gencomp.cpp} | 61 +- keybuf.c => keybuf.cpp | 2 +- main.c => main.cpp | 0 memory.c => memory.cpp | 18 +- missing.c => missing.cpp | 4 + moduleripper.c => moduleripper.cpp | 11 +- native2amiga.c => native2amiga.cpp | 0 ncr_scsi.c => ncr_scsi.cpp | 8 +- newcpu.c => newcpu.cpp | 19 +- nogui.c => nogui.cpp | 0 od-win32/{7zplugin.c => 7zplugin.cpp} | 0 ...hidsound_dsonly.c => ahidsound_dsonly.cpp} | 44 +- .../{ahidsound_new.c => ahidsound_new.cpp} | 10 +- .../{ahidsound_new2.c => ahidsound_new2.cpp} | 0 ...dsound_unified.c => ahidsound_unified.cpp} | 0 .../{ahidsoundx_new.c => ahidsoundx_new.cpp} | 0 od-win32/{avioutput.c => avioutput.cpp} | 43 +- od-win32/avioutput.h | 6 +- ...dev_win32_aspi.c => blkdev_win32_aspi.cpp} | 16 +- ...v_win32_ioctl.c => blkdev_win32_ioctl.cpp} | 8 +- ...dev_win32_spti.c => blkdev_win32_spti.cpp} | 23 +- od-win32/{bsdsock.c => bsdsock.cpp} | 50 +- od-win32/build68k_msvc/build68k_msvc.rc | 61 - od-win32/build68k_msvc/build68k_msvc.vcproj | 26 +- od-win32/build68k_msvc/build68k_msvc.vcxproj | 12 +- .../build68k_msvc.vcxproj.filters | 2 +- .../caps/{caps_win32.c => caps_win32.cpp} | 5 +- ...{clipboard_win32.c => clipboard_win32.cpp} | 30 +- od-win32/{clirun.c => clirun.cpp} | 0 ...rmGuestIPC.c => RetroPlatformGuestIPC.cpp} | 0 od-win32/{debug_win32.c => debug_win32.cpp} | 22 +- od-win32/{dinput.c => dinput.cpp} | 51 +- od-win32/direct3d.cpp | 5 +- od-win32/{diskutil.c => diskutil.cpp} | 0 ...riveclick_win32.c => driveclick_win32.cpp} | 0 od-win32/{dxwrap.c => dxwrap.cpp} | 10 +- od-win32/dxwrap.h | 4 +- od-win32/{fdrawcmd.c => fdrawcmd.cpp} | 0 od-win32/{fsdb_mywin32.c => fsdb_mywin32.cpp} | 44 +- od-win32/{fsdb_win32.c => fsdb_win32.cpp} | 32 +- .../genblitter_msvc/genblitter_msvc.vcproj | 4 +- .../genblitter_msvc/genblitter_msvc.vcxproj | 14 +- .../genblitter_msvc.vcxproj.filters | 4 +- od-win32/gencomp_msvc/gencomp_msvc.vcproj | 8 +- od-win32/gencomp_msvc/gencomp_msvc.vcxproj | 10 +- .../gencomp_msvc/gencomp_msvc.vcxproj.filters | 8 +- od-win32/gencpu_msvc/gencpu.exe.manifest | 10 - od-win32/gencpu_msvc/gencpu_msvc.vcproj | 10 +- od-win32/gencpu_msvc/gencpu_msvc.vcxproj | 16 +- .../gencpu_msvc/gencpu_msvc.vcxproj.filters | 10 +- .../genlinetoscr_msvc.vcproj | 18 +- .../genlinetoscr_msvc.vcxproj | 11 +- .../genlinetoscr_msvc.vcxproj.filters | 2 +- .../{hardfile_win32.c => hardfile_win32.cpp} | 147 +- od-win32/{hq2x_d3d.c => hq2x_d3d.cpp} | 0 od-win32/{ioport.c => ioport.cpp} | 2 + od-win32/{ipctester.c => ipctester.cpp} | 0 .../{keyboard_win32.c => keyboard_win32.cpp} | 0 od-win32/{lcd.c => lcd.cpp} | 4 +- od-win32/machdep/{support.c => support.cpp} | 0 od-win32/{midi.c => midi.cpp} | 10 +- od-win32/{midiin.c => midiin.cpp} | 0 od-win32/mman.c | 689 ------- od-win32/mman.cpp | 690 +++++++ od-win32/{opengl.c => opengl.cpp} | 0 od-win32/{parser.c => parser.cpp} | 63 +- .../{picasso96_win.c => picasso96_win.cpp} | 146 +- od-win32/picasso96_win.h | 6 +- od-win32/{posixemu.c => posixemu.cpp} | 6 +- od-win32/{registry.c => registry.cpp} | 52 +- od-win32/{rp.c => rp.cpp} | 2 +- od-win32/{scaler.c => scaler.cpp} | 7 +- od-win32/{scaler2.c => scaler2.cpp} | 0 od-win32/{scaler_more.c => scaler_more.cpp} | 0 od-win32/{screenshot.c => screenshot.cpp} | 17 +- od-win32/{serial_win32.c => serial_win32.cpp} | 6 +- od-win32/{sfhelper.c => sfhelper.cpp} | 0 od-win32/{shm.c => shm.cpp} | 0 od-win32/{soundcheck.c => soundcheck.cpp} | 0 od-win32/sounddep/{sound.c => sound.cpp} | 163 +- od-win32/sounddep/sound.h | 4 +- od-win32/srcrelease.cmd | 43 +- od-win32/{support.c => support.cpp} | 0 od-win32/{tun.c => tun.cpp} | 0 od-win32/uaeunp/uaeunp.vcproj | 100 +- od-win32/uaeunp/uaeunp.vcxproj | 103 +- od-win32/uaeunp/uaeunp.vcxproj.filters | 100 +- od-win32/{uaeunp_win32.c => uaeunp_win32.cpp} | 4 +- od-win32/{unicode.c => unicode.cpp} | 16 +- od-win32/{win32.c => win32.cpp} | 56 +- od-win32/win32.h | 7 +- ...in32_decompress.c => win32_decompress.cpp} | 0 .../{win32_filesys.c => win32_filesys.cpp} | 2 +- od-win32/{win32_nogui.c => win32_nogui.cpp} | 0 .../{win32_scale2x.c => win32_scale2x.cpp} | 6 +- od-win32/{win32_uaenet.c => win32_uaenet.cpp} | 25 +- od-win32/{win32gfx.c => win32gfx.cpp} | 19 +- od-win32/win32gfx.h | 4 +- od-win32/{win32gui.c => win32gui.cpp} | 147 +- od-win32/win32gui.h | 2 +- .../{win32gui_extra.c => win32gui_extra.cpp} | 16 +- od-win32/winuae_msvc/winuae_msvc.vcproj | 314 +-- od-win32/winuae_msvc10/winuae_msvc.vcproj | 1815 ----------------- od-win32/winuae_msvc10/winuae_msvc.vcxproj | 331 +-- .../winuae_msvc10/winuae_msvc.vcxproj.filters | 314 +-- od-win32/winuaechangelog.txt | 17 +- od-win32/{writelog.c => writelog.cpp} | 13 +- p96_blit.c => p96_blit.cpp | 0 picasso96.c => picasso96.cpp | 0 prowizard/include/extern.h | 4 +- prowizard/include/globals.h | 1 - prowizard/misc/misc.c | 24 +- readcpu.c => readcpu.cpp | 2 +- readdisk.c => readdisk.cpp | 0 rommgr.c => rommgr.cpp | 20 +- rpc.c => rpc.cpp | 0 sampler.c => sampler.cpp | 2 +- sana2.c => sana2.cpp | 16 +- savestate.c => savestate.cpp | 16 +- scsi.c => scsi.cpp | 4 +- scsidev.c => scsidev.cpp | 0 scsiemul.c => scsiemul.cpp | 0 serial.c => serial.cpp | 0 sinctable.c => sinctable.cpp | 0 traps.c => traps.cpp | 4 +- uaeexe.c => uaeexe.cpp | 6 +- uaeipc.c => uaeipc.cpp | 38 +- uaelib.c => uaelib.cpp | 0 uaeresource.c => uaeresource.cpp | 0 uaeserial.c => uaeserial.cpp | 7 +- uaeunp.c => uaeunp.cpp | 18 +- writelog.c => writelog.cpp | 0 zfile.c => zfile.cpp | 105 +- zfile_archive.c => zfile_archive.cpp | 58 +- 261 files changed, 3569 insertions(+), 5559 deletions(-) rename a2065.c => a2065.cpp (99%) rename a2091.c => a2091.cpp (99%) rename adide.c => adide.cpp (100%) rename akiko.c => akiko.cpp (99%) rename akiko2.c => akiko2.cpp (100%) rename amax.c => amax.cpp (98%) rename ar.c => ar.cpp (99%) rename arcadia.c => arcadia.cpp (98%) rename archivers/7z/{7zBuf.c => 7zBuf.cpp} (100%) rename archivers/7z/{7zCrc.c => 7zCrc.cpp} (100%) rename archivers/7z/{7zStream.c => 7zStream.cpp} (100%) rename archivers/7z/Archive/7z/{7zAlloc.c => 7zAlloc.cpp} (100%) rename archivers/7z/Archive/7z/{7zDecode.c => 7zDecode.cpp} (100%) rename archivers/7z/Archive/7z/{7zExtract.c => 7zExtract.cpp} (100%) rename archivers/7z/Archive/7z/{7zHeader.c => 7zHeader.cpp} (100%) rename archivers/7z/Archive/7z/{7zIn.c => 7zIn.cpp} (100%) rename archivers/7z/Archive/7z/{7zItem.c => 7zItem.cpp} (100%) rename archivers/7z/{Bcj2.c => Bcj2.cpp} (100%) rename archivers/7z/{Bra.c => Bra.cpp} (100%) rename archivers/7z/{Bra86.c => Bra86.cpp} (100%) rename archivers/7z/{LzmaDec.c => LzmaDec.cpp} (100%) rename archivers/dms/{crc_csum.c => crc_csum.cpp} (100%) rename archivers/dms/{getbits.c => getbits.cpp} (100%) rename archivers/dms/{maketbl.c => maketbl.cpp} (100%) rename archivers/dms/{pfile.c => pfile.cpp} (98%) rename archivers/dms/{tables.c => tables.cpp} (100%) rename archivers/dms/{u_deep.c => u_deep.cpp} (95%) rename archivers/dms/{u_heavy.c => u_heavy.cpp} (98%) rename archivers/dms/{u_init.c => u_init.cpp} (100%) rename archivers/dms/{u_medium.c => u_medium.cpp} (100%) rename archivers/dms/{u_quick.c => u_quick.cpp} (100%) rename archivers/dms/{u_rle.c => u_rle.cpp} (100%) rename archivers/lha/{crcio.c => crcio.cpp} (91%) rename archivers/lha/{dhuf.c => dhuf.cpp} (95%) rename archivers/lha/{header.c => header.cpp} (94%) rename archivers/lha/{huf.c => huf.cpp} (95%) rename archivers/lha/{larc.c => larc.cpp} (89%) rename archivers/lha/{lhamaketbl.c => lhamaketbl.cpp} (92%) rename archivers/lha/{lharc.c => lharc.cpp} (89%) rename archivers/lha/{shuf.c => shuf.cpp} (91%) rename archivers/lha/{slide.c => slide.cpp} (99%) rename archivers/lha/{uae_lha.c => uae_lha.cpp} (99%) rename archivers/lha/{util.c => util.cpp} (96%) rename archivers/lzx/{unlzx.c => unlzx.cpp} (98%) delete mode 100644 archivers/wrp/warp.c create mode 100644 archivers/wrp/warp.cpp rename archivers/xfd/{main.c => main.cpp} (100%) rename archivers/xfd/{xfd.c => xfd.cpp} (100%) rename archivers/zip/{unzip.c => unzip.cpp} (91%) rename audio.c => audio.cpp (99%) rename autoconf.c => autoconf.cpp (99%) rename blitops.c => blitops.cpp (100%) rename blitter.c => blitter.cpp (99%) rename blkdev.c => blkdev.cpp (98%) rename blkdev_cdimage.c => blkdev_cdimage.cpp (99%) rename bsdsocket.c => bsdsocket.cpp (98%) rename build68k.c => build68k.cpp (100%) rename catweasel.c => catweasel.cpp (99%) rename cd32_fmv.c => cd32_fmv.cpp (99%) rename cdrom.c => cdrom.cpp (100%) rename cdtv.c => cdtv.cpp (100%) rename cfgfile.c => cfgfile.cpp (99%) rename cia.c => cia.cpp (99%) rename consolehook.c => consolehook.cpp (96%) rename core.cw4.c => core.cw4.cpp (100%) rename cpummu.c => cpummu.cpp (100%) rename cpuopti.c => cpuopti.cpp (100%) rename crc32.c => crc32.cpp (96%) rename custom.c => custom.cpp (99%) rename debug.c => debug.cpp (98%) rename disk.c => disk.cpp (98%) rename diskutil.c => diskutil.cpp (100%) rename dongle.c => dongle.cpp (100%) rename drawing.c => drawing.cpp (99%) rename driveclick.c => driveclick.cpp (98%) rename enforcer.c => enforcer.cpp (99%) rename epsonprinter.c => epsonprinter.cpp (99%) rename ersatz.c => ersatz.cpp (100%) rename expansion.c => expansion.cpp (99%) rename fdi2raw.c => fdi2raw.cpp (99%) rename filesys.c => filesys.cpp (96%) rename filesys_bootrom.c => filesys_bootrom.cpp (100%) rename fpp.c => fpp.cpp (99%) rename fsdb.c => fsdb.cpp (94%) rename fsdb_unix.c => fsdb_unix.cpp (100%) rename fsusage.c => fsusage.cpp (100%) rename gayle.c => gayle.cpp (98%) rename genblitter.c => genblitter.cpp (100%) rename gencpu.c => gencpu.cpp (99%) rename gencpu_mini.c => gencpu_mini.cpp (100%) rename gengenblitter.c => gengenblitter.cpp (100%) rename genlinetoscr.c => genlinetoscr.cpp (98%) rename genp2c.c => genp2c.cpp (100%) rename gfxlib.c => gfxlib.cpp (100%) rename gfxutil.c => gfxutil.cpp (100%) rename gtkui.c => gtkui.cpp (100%) rename hardfile.c => hardfile.cpp (97%) rename hrtmon.rom.c => hrtmon.rom.cpp (100%) rename identify.c => identify.cpp (100%) rename inprec.c => inprec.cpp (100%) rename inputdevice.c => inputdevice.cpp (99%) rename jit/{codegen_x86.c => codegen_x86.cpp} (100%) rename jit/{compemu_fpp.c => compemu_fpp.cpp} (100%) rename jit/{compemu_optimizer_x86.c => compemu_optimizer_x86.cpp} (100%) rename jit/{compemu_raw_x86.c => compemu_raw_x86.cpp} (99%) rename jit/{compemu_support.c => compemu_support.cpp} (99%) rename jit/{compemu_support_codegen.c => compemu_support_codegen.cpp} (100%) rename jit/{gencomp.c => gencomp.cpp} (98%) rename keybuf.c => keybuf.cpp (99%) rename main.c => main.cpp (100%) rename memory.c => memory.cpp (99%) rename missing.c => missing.cpp (97%) rename moduleripper.c => moduleripper.cpp (96%) rename native2amiga.c => native2amiga.cpp (100%) rename ncr_scsi.c => ncr_scsi.cpp (99%) rename newcpu.c => newcpu.cpp (99%) rename nogui.c => nogui.cpp (100%) rename od-win32/{7zplugin.c => 7zplugin.cpp} (100%) rename od-win32/{ahidsound_dsonly.c => ahidsound_dsonly.cpp} (94%) rename od-win32/{ahidsound_new.c => ahidsound_new.cpp} (99%) rename od-win32/{ahidsound_new2.c => ahidsound_new2.cpp} (100%) rename od-win32/{ahidsound_unified.c => ahidsound_unified.cpp} (100%) rename od-win32/{ahidsoundx_new.c => ahidsoundx_new.cpp} (100%) rename od-win32/{avioutput.c => avioutput.cpp} (97%) rename od-win32/{blkdev_win32_aspi.c => blkdev_win32_aspi.cpp} (98%) rename od-win32/{blkdev_win32_ioctl.c => blkdev_win32_ioctl.cpp} (99%) rename od-win32/{blkdev_win32_spti.c => blkdev_win32_spti.cpp} (95%) rename od-win32/{bsdsock.c => bsdsock.cpp} (98%) delete mode 100644 od-win32/build68k_msvc/build68k_msvc.rc rename od-win32/caps/{caps_win32.c => caps_win32.cpp} (99%) rename od-win32/{clipboard_win32.c => clipboard_win32.cpp} (96%) rename od-win32/{clirun.c => clirun.cpp} (100%) rename od-win32/cloanto/{RetroPlatformGuestIPC.c => RetroPlatformGuestIPC.cpp} (100%) rename od-win32/{debug_win32.c => debug_win32.cpp} (99%) rename od-win32/{dinput.c => dinput.cpp} (97%) rename od-win32/{diskutil.c => diskutil.cpp} (100%) rename od-win32/{driveclick_win32.c => driveclick_win32.cpp} (100%) rename od-win32/{dxwrap.c => dxwrap.cpp} (99%) rename od-win32/{fdrawcmd.c => fdrawcmd.cpp} (100%) rename od-win32/{fsdb_mywin32.c => fsdb_mywin32.cpp} (91%) rename od-win32/{fsdb_win32.c => fsdb_win32.cpp} (94%) delete mode 100644 od-win32/gencpu_msvc/gencpu.exe.manifest rename od-win32/{hardfile_win32.c => hardfile_win32.cpp} (93%) rename od-win32/{hq2x_d3d.c => hq2x_d3d.cpp} (100%) rename od-win32/{ioport.c => ioport.cpp} (99%) rename od-win32/{ipctester.c => ipctester.cpp} (100%) rename od-win32/{keyboard_win32.c => keyboard_win32.cpp} (100%) rename od-win32/{lcd.c => lcd.cpp} (96%) rename od-win32/machdep/{support.c => support.cpp} (100%) rename od-win32/{midi.c => midi.cpp} (98%) rename od-win32/{midiin.c => midiin.cpp} (100%) delete mode 100644 od-win32/mman.c create mode 100644 od-win32/mman.cpp rename od-win32/{opengl.c => opengl.cpp} (100%) rename od-win32/{parser.c => parser.cpp} (93%) rename od-win32/{picasso96_win.c => picasso96_win.cpp} (98%) rename od-win32/{posixemu.c => posixemu.cpp} (98%) rename od-win32/{registry.c => registry.cpp} (87%) rename od-win32/{rp.c => rp.cpp} (99%) rename od-win32/{scaler.c => scaler.cpp} (99%) rename od-win32/{scaler2.c => scaler2.cpp} (100%) rename od-win32/{scaler_more.c => scaler_more.cpp} (100%) rename od-win32/{screenshot.c => screenshot.cpp} (96%) rename od-win32/{serial_win32.c => serial_win32.cpp} (99%) rename od-win32/{sfhelper.c => sfhelper.cpp} (100%) rename od-win32/{shm.c => shm.cpp} (100%) rename od-win32/{soundcheck.c => soundcheck.cpp} (100%) rename od-win32/sounddep/{sound.c => sound.cpp} (90%) rename od-win32/{support.c => support.cpp} (100%) rename od-win32/{tun.c => tun.cpp} (100%) rename od-win32/{uaeunp_win32.c => uaeunp_win32.cpp} (89%) rename od-win32/{unicode.c => unicode.cpp} (96%) rename od-win32/{win32.c => win32.cpp} (98%) rename od-win32/{win32_decompress.c => win32_decompress.cpp} (100%) rename od-win32/{win32_filesys.c => win32_filesys.cpp} (99%) rename od-win32/{win32_nogui.c => win32_nogui.cpp} (100%) rename od-win32/{win32_scale2x.c => win32_scale2x.cpp} (99%) rename od-win32/{win32_uaenet.c => win32_uaenet.cpp} (91%) rename od-win32/{win32gfx.c => win32gfx.cpp} (99%) rename od-win32/{win32gui.c => win32gui.cpp} (99%) rename od-win32/{win32gui_extra.c => win32gui_extra.cpp} (92%) delete mode 100644 od-win32/winuae_msvc10/winuae_msvc.vcproj rename od-win32/{writelog.c => writelog.cpp} (98%) rename p96_blit.c => p96_blit.cpp (100%) rename picasso96.c => picasso96.cpp (100%) rename readcpu.c => readcpu.cpp (99%) rename readdisk.c => readdisk.cpp (100%) rename rommgr.c => rommgr.cpp (98%) rename rpc.c => rpc.cpp (100%) rename sampler.c => sampler.cpp (98%) rename sana2.c => sana2.cpp (99%) rename savestate.c => savestate.cpp (99%) rename scsi.c => scsi.cpp (95%) rename scsidev.c => scsidev.cpp (100%) rename scsiemul.c => scsiemul.cpp (100%) rename serial.c => serial.cpp (100%) rename sinctable.c => sinctable.cpp (100%) rename traps.c => traps.cpp (99%) rename uaeexe.c => uaeexe.cpp (95%) rename uaeipc.c => uaeipc.cpp (88%) rename uaelib.c => uaelib.cpp (100%) rename uaeresource.c => uaeresource.cpp (100%) rename uaeserial.c => uaeserial.cpp (99%) rename uaeunp.c => uaeunp.cpp (98%) rename writelog.c => writelog.cpp (100%) rename zfile.c => zfile.cpp (96%) rename zfile_archive.c => zfile_archive.cpp (97%) diff --git a/a2065.c b/a2065.cpp similarity index 99% rename from a2065.c rename to a2065.cpp index c6d35bd6..1d4c4fbe 100644 --- a/a2065.c +++ b/a2065.cpp @@ -515,7 +515,7 @@ static void chip_init (void) uaenet_close (sysdata); if (td != NULL) { if (!sysdata) - sysdata = xcalloc (uaenet_getdatalenght(), 1); + sysdata = xcalloc (uae_u8, uaenet_getdatalenght()); if (!uaenet_open (sysdata, td, NULL, gotfunc, getfunc, prom)) { write_log (L"A2065: failed to initialize winpcap driver\n"); } @@ -719,7 +719,7 @@ static void REGPARAM2 a2065_lput (uaecptr addr, uae_u32 l) a2065_wput (addr + 2, l); } -static addrbank a2065_bank; +extern addrbank a2065_bank; static void REGPARAM2 a2065_bput (uaecptr addr, uae_u32 b) { diff --git a/a2091.c b/a2091.cpp similarity index 99% rename from a2091.c rename to a2091.cpp index 4b1f45de..32237438 100644 --- a/a2091.c +++ b/a2091.cpp @@ -1205,7 +1205,7 @@ int addscsi (int ch, TCHAR *path, int blocksize, int readonly, freescsi (scsis[ch]); scsis[ch] = NULL; - hfd = xcalloc (sizeof (struct hd_hardfiledata), 1); + hfd = xcalloc (struct hd_hardfiledata, 1); if (!hdf_hd_open (hfd, path, blocksize, readonly, devname, sectors, surfaces, reserved, bootpri, filesys)) return 0; hfd->ansi_version = scsi_level; @@ -1350,7 +1350,7 @@ void a2091_init (void) if (z) { write_log (L"A590/A2091 BOOT ROM %d.%d ", rd->ver, rd->rev); rom_size = rd->size; - rom = xmalloc (rom_size); + rom = xmalloc (uae_u8, rom_size); if (rl->rd->id == 56) rombankswitcher = 1; zfile_fread (rom, rom_size, 1, z); diff --git a/adide.c b/adide.cpp similarity index 100% rename from adide.c rename to adide.cpp diff --git a/akiko.c b/akiko.cpp similarity index 99% rename from akiko.c rename to akiko.cpp index 71a1e837..3724215e 100644 --- a/akiko.c +++ b/akiko.cpp @@ -800,7 +800,7 @@ static int cdrom_command_status (void) if (unitnum >= 0) cdrom_toc (); /* firmware info */ - strcpy (cdrom_result_buffer + 2, FIRMWAREVERSION); + memcpy (cdrom_result_buffer + 2, FIRMWAREVERSION, sizeof FIRMWAREVERSION); cdrom_result_buffer[0] = cdrom_command; cd_initialized = 1; return 20; @@ -1694,10 +1694,10 @@ int akiko_init (void) } if (!sys_cddev_open ()) { cdromok = 1; - sector_buffer_1 = xmalloc (SECTOR_BUFFER_SIZE * 2048); - sector_buffer_2 = xmalloc (SECTOR_BUFFER_SIZE * 2048); - sector_buffer_info_1 = xmalloc (SECTOR_BUFFER_SIZE); - sector_buffer_info_2 = xmalloc (SECTOR_BUFFER_SIZE); + sector_buffer_1 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE * 2048); + sector_buffer_2 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE * 2048); + sector_buffer_info_1 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE); + sector_buffer_info_2 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE); sector_buffer_sector_1 = -1; sector_buffer_sector_2 = -1; } @@ -1725,7 +1725,7 @@ uae_u8 *save_akiko(int *len) if (!currprefs.cs_cd32cd) return NULL; - dstbak = dst = malloc (1000); + dstbak = dst = xmalloc (uae_u8, 1000); save_u16 (0); save_u16 (0xCAFE); save_u32 (cdrom_intreq); diff --git a/akiko2.c b/akiko2.cpp similarity index 100% rename from akiko2.c rename to akiko2.cpp diff --git a/amax.c b/amax.cpp similarity index 98% rename from amax.c rename to amax.cpp index e66349db..c593c23d 100644 --- a/amax.c +++ b/amax.cpp @@ -147,7 +147,7 @@ void amax_init (void) zfile_fseek (z, 0, SEEK_END); rom_size = zfile_ftell (z); zfile_fseek (z, 0, SEEK_SET); - rom = xmalloc (rom_size); + rom = xmalloc (uae_u8, rom_size); zfile_fread (rom, rom_size, 1, z); zfile_fclose (z); write_log (L"AMAX: '%s' loaded, %d bytes\n", currprefs.amaxromfile, rom_size); diff --git a/ar.c b/ar.cpp similarity index 99% rename from ar.c rename to ar.cpp index d6829527..06e02eb8 100644 --- a/ar.c +++ b/ar.cpp @@ -1662,7 +1662,7 @@ int action_replay_load (void) return 0; } action_replay_flag = ACTION_REPLAY_INACTIVE; - armemory_rom = xmalloc (ar_rom_file_size); + armemory_rom = xmalloc (uae_u8, ar_rom_file_size); zfile_fread (armemory_rom, 1, ar_rom_file_size, f); zfile_fclose (f); if (ar_rom_file_size == 65536) { @@ -1681,7 +1681,7 @@ int action_replay_load (void) } arram_mask = arram_size - 1; arrom_mask = arrom_size - 1; - armemory_ram = xcalloc (arram_size, 1); + armemory_ram = xcalloc (uae_u8, arram_size); write_log (L"Action Replay %d installed at %08X, size %08X\n", armodel, arrom_start, arrom_size); action_replay_version(); return armodel; @@ -1739,7 +1739,7 @@ void action_replay_cleanup() #endif #ifdef ACTION_REPLAY_HRTMON -#include "hrtmon.rom.c" +#include "hrtmon.rom.cpp" #endif int hrtmon_lang = 0; @@ -2072,7 +2072,7 @@ uae_u8 *save_action_replay (int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = malloc (arram_size + sizeof ar_custom + sizeof ar_ciaa + sizeof ar_ciab + 1024); + dstbak = dst = xmalloc (uae_u8, arram_size + sizeof ar_custom + sizeof ar_ciaa + sizeof ar_ciab + 1024); save_u8 (0); save_u8 (armodel); save_u32 (get_crc32 (armemory_rom + 4, arrom_size - 4)); diff --git a/arcadia.c b/arcadia.cpp similarity index 98% rename from arcadia.c rename to arcadia.cpp index 5053b905..8b05fe7b 100644 --- a/arcadia.c +++ b/arcadia.cpp @@ -38,7 +38,7 @@ * */ -static void multigame(int); +static void multigame (int); int arcadia_flag, arcadia_coin[2]; struct arcadiarom *arcadia_bios, *arcadia_game; @@ -91,7 +91,7 @@ static int load_rom8 (TCHAR *xpath, uae_u8 *mem, int extra) struct zfile *zf; TCHAR path[MAX_DPATH]; int i; - uae_u8 *tmp = xmalloc (131072); + uae_u8 *tmp = xmalloc (uae_u8, 131072); TCHAR *bin = extra == 1 ? L".bin" : L""; memset (tmp, 0, 131072); @@ -397,7 +397,7 @@ int arcadia_map_banks (void) { if (!arcadia_bios) return 0; - arbmemory = (uae_u8*)xmalloc (allocated_arbmemory); + arbmemory = xmalloc (uae_u8, allocated_arbmemory); arbbmemory = arbmemory + bios_offset; memset (arbmemory, 0, allocated_arbmemory); if (!load_roms (arcadia_bios)) { diff --git a/archivers/7z/7zBuf.c b/archivers/7z/7zBuf.cpp similarity index 100% rename from archivers/7z/7zBuf.c rename to archivers/7z/7zBuf.cpp diff --git a/archivers/7z/7zCrc.c b/archivers/7z/7zCrc.cpp similarity index 100% rename from archivers/7z/7zCrc.c rename to archivers/7z/7zCrc.cpp diff --git a/archivers/7z/7zStream.c b/archivers/7z/7zStream.cpp similarity index 100% rename from archivers/7z/7zStream.c rename to archivers/7z/7zStream.cpp diff --git a/archivers/7z/Archive/7z/7zAlloc.c b/archivers/7z/Archive/7z/7zAlloc.cpp similarity index 100% rename from archivers/7z/Archive/7z/7zAlloc.c rename to archivers/7z/Archive/7z/7zAlloc.cpp diff --git a/archivers/7z/Archive/7z/7zDecode.c b/archivers/7z/Archive/7z/7zDecode.cpp similarity index 100% rename from archivers/7z/Archive/7z/7zDecode.c rename to archivers/7z/Archive/7z/7zDecode.cpp diff --git a/archivers/7z/Archive/7z/7zExtract.c b/archivers/7z/Archive/7z/7zExtract.cpp similarity index 100% rename from archivers/7z/Archive/7z/7zExtract.c rename to archivers/7z/Archive/7z/7zExtract.cpp diff --git a/archivers/7z/Archive/7z/7zHeader.c b/archivers/7z/Archive/7z/7zHeader.cpp similarity index 100% rename from archivers/7z/Archive/7z/7zHeader.c rename to archivers/7z/Archive/7z/7zHeader.cpp diff --git a/archivers/7z/Archive/7z/7zIn.c b/archivers/7z/Archive/7z/7zIn.cpp similarity index 100% rename from archivers/7z/Archive/7z/7zIn.c rename to archivers/7z/Archive/7z/7zIn.cpp diff --git a/archivers/7z/Archive/7z/7zItem.c b/archivers/7z/Archive/7z/7zItem.cpp similarity index 100% rename from archivers/7z/Archive/7z/7zItem.c rename to archivers/7z/Archive/7z/7zItem.cpp diff --git a/archivers/7z/Bcj2.c b/archivers/7z/Bcj2.cpp similarity index 100% rename from archivers/7z/Bcj2.c rename to archivers/7z/Bcj2.cpp diff --git a/archivers/7z/Bra.c b/archivers/7z/Bra.cpp similarity index 100% rename from archivers/7z/Bra.c rename to archivers/7z/Bra.cpp diff --git a/archivers/7z/Bra86.c b/archivers/7z/Bra86.cpp similarity index 100% rename from archivers/7z/Bra86.c rename to archivers/7z/Bra86.cpp diff --git a/archivers/7z/LzmaDec.c b/archivers/7z/LzmaDec.cpp similarity index 100% rename from archivers/7z/LzmaDec.c rename to archivers/7z/LzmaDec.cpp diff --git a/archivers/dms/crc_csum.c b/archivers/dms/crc_csum.cpp similarity index 100% rename from archivers/dms/crc_csum.c rename to archivers/dms/crc_csum.cpp diff --git a/archivers/dms/getbits.c b/archivers/dms/getbits.cpp similarity index 100% rename from archivers/dms/getbits.c rename to archivers/dms/getbits.cpp diff --git a/archivers/dms/maketbl.c b/archivers/dms/maketbl.cpp similarity index 100% rename from archivers/dms/maketbl.c rename to archivers/dms/maketbl.cpp diff --git a/archivers/dms/pfile.c b/archivers/dms/pfile.cpp similarity index 98% rename from archivers/dms/pfile.c rename to archivers/dms/pfile.cpp index e892c84b..f84b8e9e 100644 --- a/archivers/dms/pfile.c +++ b/archivers/dms/pfile.cpp @@ -47,7 +47,7 @@ static int passfound, passretries; static TCHAR modes[7][7]={L"NOCOMP",L"SIMPLE",L"QUICK ",L"MEDIUM",L"DEEP ",L"HEAVY1",L"HEAVY2"}; static USHORT PWDCRC; -UCHAR *text; +static UCHAR *text; static void log_error(int track) { @@ -84,14 +84,14 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o passfound = 0; passretries = 2; - b1 = (UCHAR *)calloc((size_t)TRACK_BUFFER_LEN,1); + b1 = xcalloc(UCHAR,TRACK_BUFFER_LEN); if (!b1) return ERR_NOMEMORY; - b2 = (UCHAR *)calloc((size_t)TRACK_BUFFER_LEN,1); + b2 = xcalloc(UCHAR,TRACK_BUFFER_LEN); if (!b2) { free(b1); return ERR_NOMEMORY; } - text = (UCHAR *)calloc((size_t)TEMP_BUFFER_LEN,1); + text = xcalloc(UCHAR,TEMP_BUFFER_LEN); if (!text) { free(b1); free(b2); @@ -365,7 +365,7 @@ static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR // did we have another cylinder 0 already? uae_u8 *p; zfile_fseek (fo, 0, SEEK_SET); - p = xcalloc (512 * 22, 1); + p = xcalloc (uae_u8, 512 * 22); zfile_fread (p, 512 * 22, 1, fo); addextra(L"BigFakeBootBlock", extra, p, 512 * 22); xfree (p); @@ -535,7 +535,7 @@ static void printbandiz(UCHAR *m, USHORT len){ if (*i == 10) { TCHAR *u; *i=0; - u = au (j); + u = au ((char*)j); write_log (L"%s\n",u); xfree (u); j=i+1; diff --git a/archivers/dms/tables.c b/archivers/dms/tables.cpp similarity index 100% rename from archivers/dms/tables.c rename to archivers/dms/tables.cpp diff --git a/archivers/dms/u_deep.c b/archivers/dms/u_deep.cpp similarity index 95% rename from archivers/dms/u_deep.c rename to archivers/dms/u_deep.cpp index e1e5dcaf..45d040ae 100644 --- a/archivers/dms/u_deep.c +++ b/archivers/dms/u_deep.cpp @@ -38,13 +38,13 @@ int init_deep_tabs=1; #define MAX_FREQ 0x8000 /* updates tree when the */ -USHORT freq[T + 1]; /* frequency table */ +static USHORT freq[T + 1]; /* frequency table */ -USHORT prnt[T + N_CHAR]; /* pointers to parent nodes, except for the */ +static USHORT prnt[T + N_CHAR]; /* pointers to parent nodes, except for the */ /* elements [T..T + N_CHAR - 1] which are used to get */ /* the positions of leaves corresponding to the codes. */ -USHORT son[T]; /* pointers to child nodes (son[], son[] + 1) */ +static USHORT son[T]; /* pointers to child nodes (son[], son[] + 1) */ diff --git a/archivers/dms/u_heavy.c b/archivers/dms/u_heavy.cpp similarity index 98% rename from archivers/dms/u_heavy.c rename to archivers/dms/u_heavy.cpp index b9de0b17..42d2eb81 100644 --- a/archivers/dms/u_heavy.c +++ b/archivers/dms/u_heavy.cpp @@ -21,7 +21,7 @@ #define N1 510 #define OFFSET 253 -USHORT left[2 * NC - 1], right[2 * NC - 1 + 9]; +static USHORT left[2 * NC - 1], right[2 * NC - 1 + 9]; static UCHAR c_len[NC], pt_len[NPT]; static USHORT c_table[4096], pt_table[256]; USHORT lastlen, np; diff --git a/archivers/dms/u_init.c b/archivers/dms/u_init.cpp similarity index 100% rename from archivers/dms/u_init.c rename to archivers/dms/u_init.cpp diff --git a/archivers/dms/u_medium.c b/archivers/dms/u_medium.cpp similarity index 100% rename from archivers/dms/u_medium.c rename to archivers/dms/u_medium.cpp diff --git a/archivers/dms/u_quick.c b/archivers/dms/u_quick.cpp similarity index 100% rename from archivers/dms/u_quick.c rename to archivers/dms/u_quick.cpp diff --git a/archivers/dms/u_rle.c b/archivers/dms/u_rle.cpp similarity index 100% rename from archivers/dms/u_rle.c rename to archivers/dms/u_rle.cpp diff --git a/archivers/lha/crcio.c b/archivers/lha/crcio.cpp similarity index 91% rename from archivers/lha/crcio.c rename to archivers/lha/crcio.cpp index ecf60ce1..3d1b2672 100644 --- a/archivers/lha/crcio.c +++ b/archivers/lha/crcio.cpp @@ -51,9 +51,7 @@ put_indicator(count) /* ------------------------------------------------------------------------ */ unsigned short -calccrc(p, n) - unsigned char *p; - unsigned int n; +calccrc(unsigned char *p, unsigned int n) { reading_size += n; #ifdef NEED_INCREMENTAL_INDICATOR @@ -66,8 +64,7 @@ calccrc(p, n) /* ------------------------------------------------------------------------ */ void -fillbuf(n) /* Shift bitbuf n bits left, read n bits */ - unsigned char n; +fillbuf(unsigned char n) /* Shift bitbuf n bits left, read n bits */ { while (n > bitcount) { n -= bitcount; @@ -87,8 +84,7 @@ fillbuf(n) /* Shift bitbuf n bits left, read n bits */ /* ------------------------------------------------------------------------ */ unsigned short -getbits(n) - unsigned char n; +getbits(unsigned char n) { unsigned short x; @@ -154,10 +150,7 @@ putbits(n, x) /* Write rightmost n bits of x */ #endif /* ------------------------------------------------------------------------ */ int -fread_crc(p, n, fp) - unsigned char *p; - int n; - struct zfile *fp; +fread_crc(unsigned char *p, int n, struct zfile *fp) { n = zfile_fread(p, 1, n, fp); @@ -167,10 +160,7 @@ fread_crc(p, n, fp) /* ------------------------------------------------------------------------ */ void -fwrite_crc(p, n, fp) - unsigned char *p; - int n; - struct zfile *fp; +fwrite_crc(unsigned char *p, int n, struct zfile *fp) { calccrc(p, n); if (verify_mode) @@ -183,7 +173,7 @@ fwrite_crc(p, n, fp) /* ------------------------------------------------------------------------ */ void -init_code_cache( /* void */ ) +init_code_cache(void) { /* called from copyfile() in util.c */ #ifdef EUC putc_euc_cache = EOF; @@ -192,7 +182,7 @@ init_code_cache( /* void */ ) } void -init_getbits( /* void */ ) +init_getbits(void) { lhabitbuf = 0; subbitbuf = 0; @@ -255,10 +245,7 @@ putc_euc(c, fd) /* ------------------------------------------------------------------------ */ int -fwrite_txt(p, n, fp) - unsigned char *p; - int n; - FILE *fp; +fwrite_txt(unsigned char *p, int n, FILE *fp) { while (--n >= 0) { if (*p != '\015' && *p != '\032') { @@ -276,10 +263,7 @@ fwrite_txt(p, n, fp) /* ------------------------------------------------------------------------ */ int -fread_txt(p, n, fp) - unsigned char *p; - int n; - FILE *fp; +fread_txt(unsigned char *p, int n, FILE *fp) { int c; int cnt = 0; @@ -337,9 +321,7 @@ fread_txt(p, n, fp) /* ------------------------------------------------------------------------ */ unsigned short -calc_header_crc(p, n) /* Thanks T.Okamoto */ - unsigned char *p; - unsigned int n; +calc_header_crc(unsigned char *p, unsigned int n) /* Thanks T.Okamoto */ { crc = 0; while (n-- > 0) diff --git a/archivers/lha/dhuf.c b/archivers/lha/dhuf.cpp similarity index 95% rename from archivers/lha/dhuf.c rename to archivers/lha/dhuf.cpp index cdf52aa5..0f215a79 100644 --- a/archivers/lha/dhuf.c +++ b/archivers/lha/dhuf.cpp @@ -21,7 +21,7 @@ static int most_p, nn; static unsigned long nextcount; /* ------------------------------------------------------------------------ */ void -start_c_dyn( /* void */ ) +start_c_dyn(void) { int i, j, f; @@ -56,7 +56,7 @@ start_c_dyn( /* void */ ) /* ------------------------------------------------------------------------ */ static void -start_p_dyn( /* void */ ) +start_p_dyn(void) { freq[ROOT_P] = 1; child[ROOT_P] = ~(N_CHAR); @@ -70,7 +70,7 @@ start_p_dyn( /* void */ ) /* ------------------------------------------------------------------------ */ void -decode_start_dyn( /* void */ ) +decode_start_dyn(void) { n_max = 286; maxmatch = MAXMATCH; @@ -81,9 +81,7 @@ decode_start_dyn( /* void */ ) /* ------------------------------------------------------------------------ */ static void -reconst(start, end) - int start; - int end; +reconst(int start, int end) { int i, j, k, l, b; unsigned int f, g; @@ -137,8 +135,7 @@ reconst(start, end) /* ------------------------------------------------------------------------ */ static int -swap_inc(p) - int p; +swap_inc(int p) { int b, q, r, s; @@ -178,8 +175,7 @@ Adjust: /* ------------------------------------------------------------------------ */ static void -update_c(p) - int p; +update_c(int p) { int q; @@ -195,8 +191,7 @@ update_c(p) /* ------------------------------------------------------------------------ */ static void -update_p(p) - int p; +update_p(int p) { int q; @@ -214,8 +209,7 @@ update_p(p) /* ------------------------------------------------------------------------ */ static void -make_new_node(p) - int p; +make_new_node(int p) { int q, r; @@ -269,7 +263,7 @@ encode_c_dyn(c) #endif /* ------------------------------------------------------------------------ */ unsigned short -decode_c_dyn( /* void */ ) +decode_c_dyn(void) { int c; short buf, cnt; @@ -296,7 +290,7 @@ decode_c_dyn( /* void */ ) /* ------------------------------------------------------------------------ */ unsigned short -decode_p_dyn( /* void */ ) +decode_p_dyn(void) { int c; short buf, cnt; diff --git a/archivers/lha/header.c b/archivers/lha/header.cpp similarity index 94% rename from archivers/lha/header.c rename to archivers/lha/header.cpp index dbe72861..30d5b7ea 100644 --- a/archivers/lha/header.c +++ b/archivers/lha/header.cpp @@ -16,10 +16,7 @@ /* ------------------------------------------------------------------------ */ static char *get_ptr; /* ------------------------------------------------------------------------ */ -int -calc_sum(p, len) - register char *p; - register int len; +int calc_sum(char *p, int len) { register int sum; @@ -30,8 +27,7 @@ calc_sum(p, len) } /* ------------------------------------------------------------------------ */ -static unsigned short -get_word () +static unsigned short get_word (void) { int b0, b1; @@ -41,17 +37,14 @@ get_word () } /* ------------------------------------------------------------------------ */ -static void -put_word (v) - unsigned int v; +static void put_word (unsigned int v) { put_byte (v); put_byte (v >> 8); } /* ------------------------------------------------------------------------ */ -static long -get_longword() +static long get_longword(void) { long b0, b1, b2, b3; @@ -63,9 +56,7 @@ get_longword() } /* ------------------------------------------------------------------------ */ -static void -put_longword(v) - long v; +static void put_longword(long v) { put_byte (v); put_byte (v >> 8); @@ -74,10 +65,7 @@ put_longword(v) } /* ------------------------------------------------------------------------ */ -static void -msdos_to_unix_filename(name, len) - register char *name; - register int len; +static void msdos_to_unix_filename(char *name, int len) { register int i; @@ -102,10 +90,7 @@ msdos_to_unix_filename(name, len) } /* ------------------------------------------------------------------------ */ -static void -generic_to_unix_filename(name, len) - register char *name; - register int len; +static void generic_to_unix_filename(char *name, int len) { register int i; boolean lower_case_used = FALSE; @@ -146,9 +131,7 @@ generic_to_unix_filename(name, len) /* ------------------------------------------------------------------------ */ static void -macos_to_unix_filename(name, len) - register char *name; - register int len; +macos_to_unix_filename(char *name, int len) { register int i; @@ -162,9 +145,7 @@ macos_to_unix_filename(name, len) /* ------------------------------------------------------------------------ */ static void -unix_to_generic_filename(name, len) - register char *name; - register int len; +unix_to_generic_filename(char *name, int len) { register int i; @@ -302,9 +283,7 @@ msdos_to_unix_stamp_tm(a) #endif /* ------------------------------------------------------------------------ */ -static time_t -generic_to_unix_stamp(t) - long t; +static time_t generic_to_unix_stamp(long t) #if defined(MKTIME) || defined(TIMELOCAL) { struct tm dostm; @@ -320,8 +299,8 @@ generic_to_unix_stamp(t) dostm.tm_min = t >> 5 & 0x3f; dostm.tm_hour = t >> 11 & 0x1f; dostm.tm_mday = t >> 16 & 0x1f; - dostm.tm_mon = (t >> 16 + 5 & 0x0f) - 1; /* 0..11 */ - dostm.tm_year = (t >> 16 + 9 & 0x7f) + 80; + dostm.tm_mon = ((t >> 16) + 5 & 0x0f) - 1; /* 0..11 */ + dostm.tm_year = ((t >> 16) + 9 & 0x7f) + 80; #if 0 dostm.tm_isdst = 0; /* correct? */ #endif @@ -377,9 +356,7 @@ generic_to_unix_stamp(t) #endif /* defined(MKTIME) || defined(TIMELOCAL) */ /* ------------------------------------------------------------------------ */ -static long -unix_to_generic_stamp(t) - time_t t; +static long unix_to_generic_stamp(time_t t) { struct tm *tm = localtime(&t); @@ -394,10 +371,7 @@ unix_to_generic_stamp(t) /* ------------------------------------------------------------------------ */ /* build header functions */ /* ------------------------------------------------------------------------ */ -boolean -get_header(fp, hdr) - struct zfile *fp; - register LzHeader *hdr; +boolean get_header(struct zfile *fp, LzHeader *hdr) { int header_size; int name_length; @@ -554,7 +528,7 @@ get_header(fp, hdr) for (i = 0; i < header_size - 3; i++) dirname[i] = (char) get_byte (); dirname[header_size - 3] = '\0'; - convdelim(dirname, DELIM); + convdelim((unsigned char*)dirname, DELIM); dir_length = header_size - 3; break; case 0x40: @@ -663,11 +637,7 @@ get_header(fp, hdr) } /* ------------------------------------------------------------------------ */ -void -init_header(name, v_stat, hdr) - char *name; - struct stat *v_stat; - LzHeader *hdr; +void init_header(char *name, struct stat *v_stat, LzHeader *hdr) { int len; diff --git a/archivers/lha/huf.c b/archivers/lha/huf.cpp similarity index 95% rename from archivers/lha/huf.c rename to archivers/lha/huf.cpp index 33d23a25..e6ddd3f7 100644 --- a/archivers/lha/huf.c +++ b/archivers/lha/huf.cpp @@ -32,8 +32,7 @@ static int np; /* ------------------------------------------------------------------------ */ /* Encording */ /* ------------------------------------------------------------------------ */ -static void -count_t_freq(/*void*/) +static void count_t_freq(void) { short i, k, n, count; @@ -253,8 +252,7 @@ output_st1(c, p) #endif /* ------------------------------------------------------------------------ */ -unsigned char * -alloc_buf( /* void */ ) +unsigned char *alloc_buf(void) { bufsiz = 16 * 1024 *2; /* 65408U; */ /* t.okamoto */ while ((buf = (unsigned char *) malloc(bufsiz)) == NULL) { @@ -315,11 +313,7 @@ encode_end_st1( /* void */ ) /* ------------------------------------------------------------------------ */ /* decoding */ /* ------------------------------------------------------------------------ */ -static void -read_pt_len(nn, nbit, i_special) - short nn; - short nbit; - short i_special; +static void read_pt_len(short nn, short nbit, short i_special) { int i, c, n; @@ -352,13 +346,12 @@ read_pt_len(nn, nbit, i_special) } while (i < nn) pt_len[i++] = 0; - make_table(nn, pt_len, 8, pt_table); + lha_make_table(nn, pt_len, 8, pt_table); } } /* ------------------------------------------------------------------------ */ -static void -read_c_len( /* void */ ) +static void read_c_len(void) { short i, c, n; @@ -399,13 +392,12 @@ read_c_len( /* void */ ) } while (i < NC) c_len[i++] = 0; - make_table(NC, c_len, 12, c_table); + lha_make_table(NC, c_len, 12, c_table); } } /* ------------------------------------------------------------------------ */ -unsigned short -decode_c_st1( /*void*/ ) +unsigned short decode_c_st1(void) { unsigned short j, mask; @@ -435,8 +427,7 @@ decode_c_st1( /*void*/ ) } /* ------------------------------------------------------------------------ */ -unsigned short -decode_p_st1( /* void */ ) +unsigned short decode_p_st1(void) { unsigned short j, mask; @@ -461,8 +452,7 @@ decode_p_st1( /* void */ ) } /* ------------------------------------------------------------------------ */ -void -decode_start_st1( /* void */ ) +void decode_start_st1(void) { if (dicbit <= 13) { np = 14; diff --git a/archivers/lha/larc.c b/archivers/lha/larc.cpp similarity index 89% rename from archivers/lha/larc.c rename to archivers/lha/larc.cpp index a6a2642c..a1a9d43e 100644 --- a/archivers/lha/larc.c +++ b/archivers/lha/larc.cpp @@ -11,8 +11,7 @@ /* ------------------------------------------------------------------------ */ static int flag, flagcnt, matchpos; /* ------------------------------------------------------------------------ */ -unsigned short -decode_c_lzs( /*void*/ ) +unsigned short decode_c_lzs(void) { if (getbits(1)) { return getbits(8); @@ -24,22 +23,19 @@ decode_c_lzs( /*void*/ ) } /* ------------------------------------------------------------------------ */ -unsigned short -decode_p_lzs( /*void*/ ) +unsigned short decode_p_lzs(void) { return (loc - matchpos - MAGIC0) & 0x7ff; } /* ------------------------------------------------------------------------ */ -void -decode_start_lzs( /*void*/ ) +void decode_start_lzs(void) { init_getbits(); } /* ------------------------------------------------------------------------ */ -unsigned short -decode_c_lz5( /*void*/ ) +unsigned short decode_c_lz5(void) { int c; @@ -61,15 +57,13 @@ decode_c_lz5( /*void*/ ) } /* ------------------------------------------------------------------------ */ -unsigned short -decode_p_lz5( /*void*/ ) +unsigned short decode_p_lz5(void) { return (loc - matchpos - MAGIC5) & 0xfff; } /* ------------------------------------------------------------------------ */ -void -decode_start_lz5( /*void*/ ) +void decode_start_lz5(void) { int i; diff --git a/archivers/lha/lha.h b/archivers/lha/lha.h index 9415584a..34a123c0 100644 --- a/archivers/lha/lha.h +++ b/archivers/lha/lha.h @@ -229,13 +229,13 @@ extern void build_standard_archive_name(); extern FILE *open_old_archive(); extern void init_header(); -extern boolean get_header(); +extern boolean get_header(struct zfile *fp, LzHeader *hdr); extern boolean archive_is_msdos_sfx1(); extern boolean skip_msdos_sfx1_code(); extern void write_header(); extern void write_archive_tail(); extern void copy_old_one(); -extern unsigned char *convdelim(); +extern unsigned char *convdelim(unsigned char *path, unsigned char delim); extern long copyfile(); extern void cmd_list(), cmd_extract(), cmd_add(), cmd_delete(); @@ -246,7 +246,7 @@ extern char *extract_directory; extern int encode_alloc(); extern void encode(); -extern int decode(); +extern int decode(struct interfacing*); /* from append.c */ extern void start_indicator(); @@ -289,8 +289,8 @@ extern unsigned short decode_p_lz5(); extern void decode_start_lzs(); extern void decode_start_lz5(); -extern void make_table( /* int nchar, uchar bitlen[], int tablebits, - ushort table[] */ ); +extern void lha_make_table(short nchar, unsigned char bitlen[], short tablebits, unsigned short table[]); + /* from maketree.c */ /* @@ -303,13 +303,13 @@ extern short make_tree( /* int nparm, ushort freqparm[], uchar lenparm[], /* from crcio.c */ extern void make_crctable(); -extern unsigned short calccrc( /* uchar *p, uint n */ ); -extern void fillbuf( /* uchar n */ ); -extern unsigned short getbits( /* uchar n */ ); -extern void putcode( /* uchar n, ushort x */ ); -extern void putbits( /* uchar n, ushort x */ ); -extern int fread_crc( /* uchar *p, int n, FILE *f */ ); -extern void fwrite_crc( /* uchar *p, int n, FILE *f */ ); +extern unsigned short calccrc(unsigned char *p, unsigned int n); +extern void fillbuf(unsigned char n); +extern unsigned short getbits(unsigned char n); +extern void putcode(unsigned char n, unsigned short x); +extern void putbits(unsigned char n, unsigned short x); +extern int fread_crc(unsigned char *p, int n, struct zfile *f); +extern void fwrite_crc(unsigned char *p, int n, struct zfile *f); extern void init_getbits(); extern void init_putbits(); extern void make_crctable(); diff --git a/archivers/lha/lhamaketbl.c b/archivers/lha/lhamaketbl.cpp similarity index 92% rename from archivers/lha/lhamaketbl.c rename to archivers/lha/lhamaketbl.cpp index 00bf544f..791636b9 100644 --- a/archivers/lha/lhamaketbl.c +++ b/archivers/lha/lhamaketbl.cpp @@ -8,12 +8,7 @@ /* ------------------------------------------------------------------------ */ #include "lha.h" -void -lha_make_table(nchar, bitlen, tablebits, table) - short nchar; - unsigned char bitlen[]; - short tablebits; - unsigned short table[]; +void lha_make_table(short nchar, unsigned char bitlen[], short tablebits, unsigned short table[]) { unsigned short count[17]; /* count of bitlen */ unsigned short weight[17]; /* 0x10000ul >> bitlen */ diff --git a/archivers/lha/lharc.c b/archivers/lha/lharc.cpp similarity index 89% rename from archivers/lha/lharc.c rename to archivers/lha/lharc.cpp index 6c23f0e4..6d006cb4 100644 --- a/archivers/lha/lharc.c +++ b/archivers/lha/lharc.cpp @@ -129,9 +129,7 @@ init_variable() /* Added N.Watazaki */ /* ------------------------------------------------------------------------ */ /* */ /* ------------------------------------------------------------------------ */ -static int -sort_by_ascii(a, b) - char **a, **b; +static int sort_by_ascii(char **a, char **b) { register char *p, *q; register int c1, c2; @@ -159,12 +157,9 @@ sort_by_ascii(a, b) } /* ------------------------------------------------------------------------ */ -char * -xrealloc(old, size) - char *old; - int size; +char *xxrealloc(char *old, int size) { - char *p = (char *) realloc(old, size); + char *p = (char *) xrealloc(char, old, size); if (!p) fatal_error(L"Not enough memory"); return p; @@ -189,26 +184,20 @@ xrealloc(old, size) */ /* ------------------------------------------------------------------------ */ -void -init_sp(sp) - struct string_pool *sp; +void init_sp(struct string_pool *sp) { sp->size = 1024 - 8; /* any ( >=0 ) */ sp->used = 0; sp->n = 0; - sp->buffer = (char *) xmalloc(sp->size * sizeof(char)); + sp->buffer = (char *) xmalloc(char, sp->size); } /* ------------------------------------------------------------------------ */ -void -add_sp(sp, name, len) - struct string_pool *sp; - char *name; /* stored '\0' at tail */ - int len; /* include '\0' */ +void add_sp(struct string_pool *sp, char *name, int len) { while (sp->used + len > sp->size) { sp->size *= 2; - sp->buffer = (char *) xrealloc(sp->buffer, sp->size * sizeof(char)); + sp->buffer = (char *) xxrealloc(sp->buffer, sp->size * sizeof(char)); } bcopy(name, sp->buffer + sp->used, len); sp->used += len; @@ -216,17 +205,13 @@ add_sp(sp, name, len) } /* ------------------------------------------------------------------------ */ -void -finish_sp(sp, v_count, v_vector) - register struct string_pool *sp; - int *v_count; - char ***v_vector; +void finish_sp(struct string_pool *sp, int *v_count, char ***v_vector) { int i; register char *p; char **v; - v = (char **) xmalloc((sp->n + 1) * sizeof(char *)); + v = (char **) xmalloc(char*, sp->n + 1); *v++ = sp->buffer; *v_vector = v; *v_count = sp->n; @@ -239,9 +224,7 @@ finish_sp(sp, v_count, v_vector) } /* ------------------------------------------------------------------------ */ -void -free_sp(vector) - char **vector; +void free_sp(char **vector) { vector--; free(*vector); /* free string pool */ @@ -252,9 +235,7 @@ free_sp(vector) /* ------------------------------------------------------------------------ */ /* READ DIRECTORY FILES */ /* ------------------------------------------------------------------------ */ -static boolean -include_path_p(path, name) - char *path, *name; +static boolean include_path_p(char *path, char *name) { char *n = name; while (*path) diff --git a/archivers/lha/shuf.c b/archivers/lha/shuf.cpp similarity index 91% rename from archivers/lha/shuf.c rename to archivers/lha/shuf.cpp index 07d21fc8..62e9b1aa 100644 --- a/archivers/lha/shuf.c +++ b/archivers/lha/shuf.cpp @@ -21,8 +21,7 @@ int fixed[2][16] = { {2, 0x01, 0x01, 0x03, 0x06, 0x0D, 0x1F, 0x4E, 0} /* 8K buf */ }; /* ------------------------------------------------------------------------ */ -void -decode_start_st0( /*void*/ ) +void decode_start_st0(void) { n_max = 286; maxmatch = MAXMATCH; @@ -49,9 +48,7 @@ encode_p_st0(j) } #endif /* ------------------------------------------------------------------------ */ -static void -ready_made(method) - int method; +static void ready_made(int method) { int i, j; unsigned int code, weight; @@ -87,8 +84,7 @@ encode_start_fix( /*void*/ ) } #endif /* ------------------------------------------------------------------------ */ -static void -read_tree_c( /*void*/ ) +static void read_tree_c(void) { /* read tree from file */ int i, c; @@ -107,12 +103,11 @@ read_tree_c( /*void*/ ) return; } } - make_table(N1, c_len, 12, c_table); + lha_make_table(N1, c_len, 12, c_table); } /* ------------------------------------------------------------------------ */ -static void -read_tree_p(/*void*/) +static void read_tree_p(void) { /* read tree from file */ int i, c; @@ -135,8 +130,7 @@ read_tree_p(/*void*/) } /* ------------------------------------------------------------------------ */ -void -decode_start_fix(/*void*/) +void decode_start_fix(void) { n_max = 314; maxmatch = 60; @@ -144,12 +138,11 @@ decode_start_fix(/*void*/) np = 1 << (12 - 6); start_c_dyn(); ready_made(0); - make_table(np, pt_len, 8, pt_table); + lha_make_table(np, pt_len, 8, pt_table); } /* ------------------------------------------------------------------------ */ -unsigned short -decode_c_st0(/*void*/) +unsigned short decode_c_st0(void) { int i, j; static unsigned short blocksize = 0; @@ -163,7 +156,7 @@ decode_c_st0(/*void*/) else { ready_made(1); } - make_table(NP, pt_len, 8, pt_table); + lha_make_table(NP, pt_len, 8, pt_table); } blocksize--; j = c_table[lhabitbuf >> 4]; @@ -187,8 +180,7 @@ decode_c_st0(/*void*/) } /* ------------------------------------------------------------------------ */ -unsigned short -decode_p_st0(/*void*/) +unsigned short decode_p_st0(void) { int i, j; diff --git a/archivers/lha/slide.c b/archivers/lha/slide.cpp similarity index 99% rename from archivers/lha/slide.c rename to archivers/lha/slide.cpp index ab721eac..71af62be 100644 --- a/archivers/lha/slide.c +++ b/archivers/lha/slide.cpp @@ -378,9 +378,7 @@ struct interfacing *lhinterface; #endif -int -decode(lhinterface) - struct interfacing *lhinterface; +int decode(struct interfacing *lhinterface) { unsigned int i, j, k, c; unsigned int dicsiz1, offset; diff --git a/archivers/lha/uae_lha.c b/archivers/lha/uae_lha.cpp similarity index 99% rename from archivers/lha/uae_lha.c rename to archivers/lha/uae_lha.cpp index 7547269f..6d9ad2b8 100644 --- a/archivers/lha/uae_lha.c +++ b/archivers/lha/uae_lha.cpp @@ -5,10 +5,9 @@ #include "sysconfig.h" #include "sysdeps.h" -#include "zfile.h" +#include "lha.h" #include "zarchive.h" -#include "lha.h" static char *methods[] = { diff --git a/archivers/lha/util.c b/archivers/lha/util.cpp similarity index 96% rename from archivers/lha/util.c rename to archivers/lha/util.cpp index 3c9c0c9a..1492da16 100644 --- a/archivers/lha/util.c +++ b/archivers/lha/util.cpp @@ -21,10 +21,7 @@ extern unsigned short crc; /* convert path delimit erreturns *filename */ /* ------------------------------------------------------------------------ */ -unsigned char * -convdelim(path, delim) - unsigned char *path; - unsigned char delim; +unsigned char *convdelim(unsigned char *path, unsigned char delim) { unsigned char c; unsigned char *p; @@ -205,9 +202,7 @@ mkdir(path, mode) */ #ifndef USESTRCASECMP -static int -my_toupper(n) - register int n; +static int my_toupper(int n) { if (n >= 'a' && n <= 'z') return n & (~('a' - 'A')); @@ -215,9 +210,7 @@ my_toupper(n) } /* ------------------------------------------------------------------------ */ -int -strucmp(s, t) - register char *s, *t; +int strucmp(char *s, char *t) { while (my_toupper(*s++) == my_toupper(*t++)) if (!*s || !*t) diff --git a/archivers/lzx/unlzx.c b/archivers/lzx/unlzx.cpp similarity index 98% rename from archivers/lzx/unlzx.c rename to archivers/lzx/unlzx.cpp index 79530180..a7b6d6e8 100644 --- a/archivers/lzx/unlzx.c +++ b/archivers/lzx/unlzx.cpp @@ -642,9 +642,9 @@ struct zfile *archive_access_lzx (struct znode *zn) startpos = znlast->offset; compsize = znlast->packedsize; zfile_fseek (zf, startpos, SEEK_SET); - buf = xmalloc(compsize); + buf = xmalloc (uae_u8, compsize); zfile_fread (buf, compsize, 1, zf); - dbuf = xcalloc (unpsize, 1); + dbuf = xcalloc (uae_u8, unpsize); /* unpack complete block */ memset(offset_len, 0, sizeof offset_len); @@ -709,8 +709,8 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file) unsigned int pack_size; unsigned int unpack_size; unsigned char archive_header[31]; - unsigned char header_filename[256]; - unsigned char header_comment[256]; + char header_filename[256]; + char header_comment[256]; if (zfile_fread(archive_header, 1, 10, in_file) != 10) return 0; @@ -742,7 +742,7 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file) if(actual == temp) { header_filename[temp] = 0; - crc_calc(header_filename, temp); + crc_calc((unsigned char*)header_filename, temp); temp = archive_header[14]; /* comment length */ actual = zfile_fread(header_comment, 1, temp, in_file); if(!zfile_ferror(in_file)) @@ -750,7 +750,7 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file) if(actual == temp) { header_comment[temp] = 0; - crc_calc(header_comment, temp); + crc_calc((unsigned char*)header_comment, temp); if(sum == crc) { unsigned int year, month, day; diff --git a/archivers/wrp/warp.c b/archivers/wrp/warp.c deleted file mode 100644 index a1477ba9..00000000 --- a/archivers/wrp/warp.c +++ /dev/null @@ -1,481 +0,0 @@ - - -#include -#include -#include -#include - -#include "sysconfig.h" -#include "sysdeps.h" -#include "zfile.h" -#include "crc32.h" - -/* based on http://libxad.cvs.sourceforge.net/libxad/libxad/portable/clients/ by Dirk Stoecker */ - -#define XADERR_ILLEGALDATA 1 -#define XADERR_DECRUNCH 2 -#define XADERR_NOMEMORY 3 - -struct rledata { - uae_u32 rledata; -}; - -struct fout { - struct zfile *zf; - int xio_BitNum; - int xio_BitBuf; - int err; -}; - - -static void putrle (uae_u8 data, struct zfile *out, struct rledata *rled) -{ - int num; - uae_u32 a; - - if (!rled) { - zfile_putc (data, out); - return; - } - a = rled->rledata; - if (a & 0x100) /* was RLE mode */ - { - if (!data || (data == 1 && (a & 0x80000000))) { - a = 0x90; num = 1; - } else { - a &= 0xFF; num = data - 1; - } - } else if (data == 0x90) { - num = 0; a |= 0x100; - } else { - num = 1; a = data; - } - rled->rledata = a; - while (num--) - zfile_putc (a, out); -} - -static uae_u32 xadIOGetBitsLow(struct fout *io, uae_u8 bits) -{ - uae_u32 x; - - io->err = 0; - while(io->xio_BitNum < bits) - { - int v = zfile_getc (io->zf); - if (v == -1) { - io->err = 1; - return 0; - } - io->xio_BitBuf |= v << io->xio_BitNum; - io->xio_BitNum += 8; - } - x = io->xio_BitBuf & ((1<xio_BitBuf >>= bits; - io->xio_BitNum -= bits; - return x; -} - -#define ARCSQSPEOF 256 /* special endfile token */ -#define ARCSQNUMVALS 257 /* 256 data values plus SPEOF */ - -static uae_s32 ARCunsqueeze(struct zfile *in, struct zfile *out, struct rledata *rled) -{ - uae_s32 err = 0; - uae_s32 i, numnodes; - uae_s16 *node; - struct fout io; - - io.zf = in; - io.xio_BitBuf = 0; - io.xio_BitNum = 0; - io.err = 0; - - if((node = (uae_s16 *) xcalloc(2*2*ARCSQNUMVALS, 1))) - { - numnodes = xadIOGetBitsLow(&io, 16); - - if(numnodes < 0 || numnodes >= ARCSQNUMVALS) - err = XADERR_DECRUNCH; - else - { /* initialize for possible empty tree (SPEOF only) */ - node[0] = node[1] = -(ARCSQSPEOF + 1); - - numnodes *= 2; i = 0; - while(i < numnodes && !io.err) /* get decoding tree from file */ - { - node[i++] = xadIOGetBitsLow(&io, 16); - node[i++] = xadIOGetBitsLow(&io, 16); - } - - do - { - /* follow bit stream in tree to a leaf */ - i = 0; - while(i >= 0 && !io.err) - i = node[2*i + xadIOGetBitsLow(&io, 1)]; - - i = -(i + 1); /* decode fake node index to original data value */ - - if(i != ARCSQSPEOF) - putrle (i, out, rled); - } while(i != ARCSQSPEOF); - } - xfree(node); - } - else - err = XADERR_NOMEMORY; - - return err; -} - - - - -#define UCOMPMAXCODE(n) (((uae_u32) 1 << (n)) - 1) -#define UCOMPBITS 16 -#define UCOMPSTACKSIZE 8000 -#define UCOMPFIRST 257 /* first free entry */ -#define UCOMPCLEAR 256 /* table clear output code */ -#define UCOMPINIT_BITS 9 /* initial number of bits/code */ -#define UCOMPBIT_MASK 0x1f -#define UCOMPBLOCK_MASK 0x80 - -struct UCompData { - uae_s16 clear_flg; - uae_u16 n_bits; /* number of bits/code */ - uae_u16 maxbits; /* user settable max # bits/code */ - uae_u32 maxcode; /* maximum code, given n_bits */ - uae_u32 maxmaxcode; - uae_s32 free_ent; - uae_s32 offset; - uae_s32 size; - uae_u16 *tab_prefixof; - uae_u8 *tab_suffixof; - uae_u8 stack[UCOMPSTACKSIZE]; - uae_u8 buf[UCOMPBITS]; - int insize; - struct rledata *rled; -}; - - -/* Read one code from input. If EOF, return -1. */ -static uae_s32 UCompgetcode(struct zfile *in, struct UCompData *cd) -{ - uae_s32 code, r_off, bits; - uae_u8 *bp = cd->buf; - - if(cd->clear_flg > 0 || cd->offset >= cd->size || cd->free_ent > cd->maxcode) - { - /* - * If the next entry will be too big for the current code - * size, then we must increase the size. This implies reading - * a new buffer full, too. - */ - if(cd->free_ent > cd->maxcode) - { - if(++cd->n_bits == cd->maxbits) - cd->maxcode = cd->maxmaxcode; /* won't get any bigger now */ - else - cd->maxcode = UCOMPMAXCODE(cd->n_bits); - } - if(cd->clear_flg > 0) - { - cd->maxcode = UCOMPMAXCODE(cd->n_bits = UCOMPINIT_BITS); - cd->clear_flg = 0; - } - - /* This reads maximum n_bits characters into buf */ - cd->size = 0; - while(cd->size < cd->n_bits) { - int v; - if (cd->insize == 0) - break; - v = zfile_getc (in); - if (v == -1) - break; - cd->insize--; - cd->buf[cd->size++] = v; - } - if(cd->size <= 0) - return -1; - - cd->offset = 0; - /* Round size down to integral number of codes */ - cd->size = (cd->size << 3) - (cd->n_bits - 1); - } - - r_off = cd->offset; - bits = cd->n_bits; - - /* Get to the first byte. */ - bp += (r_off >> 3); - r_off &= 7; - - /* Get first part (low order bits) */ - code = (*bp++ >> r_off); - bits -= (8 - r_off); - r_off = 8 - r_off; /* now, offset into code word */ - - /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */ - if(bits >= 8) - { - code |= *bp++ << r_off; - r_off += 8; - bits -= 8; - } - - /* high order bits. */ - code |= (*bp & ((1<offset += cd->n_bits; - - return code; -} - -static uae_u32 xadIO_Compress(struct zfile *in, struct zfile *out, int insize, struct rledata *rled, uae_u8 bitinfo) -{ - int err = 0; - struct UCompData *cd; - - if((bitinfo & UCOMPBIT_MASK) < UCOMPINIT_BITS) - return XADERR_ILLEGALDATA; - - if((cd = xcalloc(sizeof(struct UCompData), 1))) - { - int finchar, code, oldcode, incode, blockcomp; - uae_u8 *stackp, *stack, *stackend; - - stackp = stack = cd->stack; - stackend = stack + UCOMPSTACKSIZE; - cd->maxbits = bitinfo & UCOMPBIT_MASK; - blockcomp = bitinfo & UCOMPBLOCK_MASK; - cd->maxmaxcode = 1 << cd->maxbits; - cd->maxcode = UCOMPMAXCODE(cd->n_bits = UCOMPINIT_BITS); - cd->free_ent = blockcomp ? UCOMPFIRST : 256; - cd->insize = insize; - cd->rled = rled; - - if((cd->tab_prefixof = xcalloc(sizeof(uae_u16) * cd->maxmaxcode, 1))) - { - if((cd->tab_suffixof = xcalloc(cd->maxmaxcode, 1))) - { - /* Initialize the first 256 entries in the table. */ - for(code = 255; code >= 0; code--) - cd->tab_suffixof[code] = code; - - if((finchar = oldcode = UCompgetcode(in, cd)) == -1) - err = XADERR_DECRUNCH; - else - { - putrle (finchar, out, cd->rled); /* first code must be 8 bits = uae_u8 */ - - while((code = UCompgetcode(in, cd)) > -1) - { - if((code == UCOMPCLEAR) && blockcomp) - { - for(code = 255; code >= 0; code--) - cd->tab_prefixof[code] = 0; - cd->clear_flg = 1; - cd->free_ent = UCOMPFIRST - 1; - if((code = UCompgetcode(in, cd)) == -1) - break; /* O, untimely death! */ - } - incode = code; - - /* Special case for KwKwK string. */ - if(code >= cd->free_ent) - { - if(code > cd->free_ent) - { - err = XADERR_ILLEGALDATA; - break; - } - *stackp++ = finchar; - code = oldcode; - } - - /* Generate output characters in reverse order */ - while(stackp < stackend && code >= 256) - { - *stackp++ = cd->tab_suffixof[code]; - code = cd->tab_prefixof[code]; - } - if(stackp >= stackend) - { - err = XADERR_ILLEGALDATA; - break; - } - *(stackp++) = finchar = cd->tab_suffixof[code]; - - /* And put them out in forward order */ - do - { - putrle (*(--stackp), out, cd->rled); - } while(stackp > stack); - - /* Generate the new entry. */ - if((code = cd->free_ent) < cd->maxmaxcode) - { - cd->tab_prefixof[code] = (uae_u16) oldcode; - cd->tab_suffixof[code] = finchar; - cd->free_ent = code+1; - } - /* Remember previous code. */ - oldcode = incode; - } - } - xfree (cd->tab_suffixof); - } - else - err = XADERR_NOMEMORY; - xfree(cd->tab_prefixof); - } - else - err = XADERR_NOMEMORY; - xfree(cd); - } - else - err = XADERR_NOMEMORY; - - return err; -} - -static void MakeCRC16(uae_u16 *buf, uae_u16 ID) -{ - uae_u16 i, j, k; - - for(i = 0; i < 256; ++i) - { - k = i; - - for(j = 0; j < 8; ++j) - { - if(k & 1) - k = (k >> 1) ^ ID; - else - k >>= 1; - } - buf[i] = k; - } -} - -static uae_u16 wrpcrc16 (uae_u16 *tab, uae_u8 *buf, int len) -{ - uae_u16 crc = 0; - while (len-- > 0) - crc = tab[(crc ^ *buf++) & 0xFF] ^ (crc >> 8); - return crc; -} - -static int iswrp (uae_u8 *data) -{ - if(data[0] == 'W' && data[1] == 'a' && data[2] == 'r' && data[3] == 'p' - && data[4] == ' ' && data[5] == 'v' && data[6] == '1' && data[7] == '.' - && data[8] == '1' && !data[9] && !data[18] && data[19] <= 3) - return 1; - return 0; -} - -#define COMPBUF 30000 - -struct zfile *unwarp(struct zfile *zf) -{ - int err = 0; - uae_u8 buf[26] = { 0 }; - int algo, side, track; - int pos, dstpos, olddstpos; - uae_u16 crc; - uae_u32 size; - struct zfile *nf = NULL, *tmpf = NULL; - uae_u8 *zero, *data; - int outsize = 11 * 512; - int outsize2 = 11 * (512 + 16); - struct rledata rled; - uae_u16 wrpcrc16table[256]; - - MakeCRC16 (wrpcrc16table, 0xa001); - - zero = xcalloc (outsize2, 1); - olddstpos = 0; - for (;;) { - if (zfile_fread (buf, sizeof buf, 1, zf) == 0) - break; - if (!iswrp (buf)) - break; - if (!nf) { - nf = zfile_fopen_empty (zf, L"zipped.wrp", 1760 * 512); - tmpf = zfile_fopen_empty (zf, L"tmp", outsize2); - } - track = (buf[10] << 8) | buf[11]; - algo = buf[19]; - side = -1; - if (!memcmp (buf + 12, "BOT\0", 4)) - side = 1; - if (!memcmp (buf + 12, "TOP\0", 4)) - side = 0; - crc = (buf[20] << 8) | buf[21]; - pos = zfile_ftell (zf); - dstpos = -1; - if (side >= 0 && track >= 0 && track <= 79) - dstpos = track * 22 * 512 + (side * 11 * 512); - zfile_fseek (tmpf, 0, SEEK_SET); - zfile_fwrite (zero, outsize2, 1, tmpf); - zfile_fseek (tmpf, 0, SEEK_SET); - size = (buf[22] << 24) | (buf[23] << 16) | (buf[24] << 8) | buf[25]; - err = 0; - memset (&rled, 0, sizeof rled); - - switch (algo) - { - case 1: - if (zfile_getc (zf) != 12) - err = XADERR_ILLEGALDATA; - else - err = xadIO_Compress (zf, tmpf, size - 1, &rled, 12 | UCOMPBLOCK_MASK); - break; - case 2: - err = ARCunsqueeze (zf, tmpf, &rled); - break; - case 0: - case 3: - { - int i; - for (i = 0; i < size; i++) { - uae_u8 v = zfile_getc (zf); - putrle (v, tmpf, algo == 3 ? &rled : NULL); - } - } - break; - default: - write_log (L"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); - } 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); - xfree (data); - } - if (dstpos >= 0) { - zfile_fseek (nf, dstpos, SEEK_SET); - data = zfile_getdata (tmpf, 0, outsize); - zfile_fwrite (data, outsize, 1, nf); - } - zfile_fseek (zf, pos + size, SEEK_SET); - } -end: - xfree (zero); - zfile_fclose (tmpf); - if (nf) { - zfile_fclose (zf); - zf = nf; - } - return zf; -} - diff --git a/archivers/wrp/warp.cpp b/archivers/wrp/warp.cpp new file mode 100644 index 00000000..529a6e41 --- /dev/null +++ b/archivers/wrp/warp.cpp @@ -0,0 +1,481 @@ + + +#include +#include +#include +#include + +#include "sysconfig.h" +#include "sysdeps.h" +#include "zfile.h" +#include "crc32.h" + +/* based on http://libxad.cvs.sourceforge.net/libxad/libxad/portable/clients/ by Dirk Stoecker */ + +#define XADERR_ILLEGALDATA 1 +#define XADERR_DECRUNCH 2 +#define XADERR_NOMEMORY 3 + +struct rledata { + uae_u32 rledatav; +}; + +struct fout { + struct zfile *zf; + int xio_BitNum; + int xio_BitBuf; + int err; +}; + + +static void putrle (uae_u8 data, struct zfile *out, struct rledata *rled) +{ + int num; + uae_u32 a; + + if (!rled) { + zfile_putc (data, out); + return; + } + a = rled->rledatav; + if (a & 0x100) /* was RLE mode */ + { + if (!data || (data == 1 && (a & 0x80000000))) { + a = 0x90; num = 1; + } else { + a &= 0xFF; num = data - 1; + } + } else if (data == 0x90) { + num = 0; a |= 0x100; + } else { + num = 1; a = data; + } + rled->rledatav = a; + while (num--) + zfile_putc (a, out); +} + +static uae_u32 xadIOGetBitsLow(struct fout *io, uae_u8 bits) +{ + uae_u32 x; + + io->err = 0; + while(io->xio_BitNum < bits) + { + int v = zfile_getc (io->zf); + if (v == -1) { + io->err = 1; + return 0; + } + io->xio_BitBuf |= v << io->xio_BitNum; + io->xio_BitNum += 8; + } + x = io->xio_BitBuf & ((1<xio_BitBuf >>= bits; + io->xio_BitNum -= bits; + return x; +} + +#define ARCSQSPEOF 256 /* special endfile token */ +#define ARCSQNUMVALS 257 /* 256 data values plus SPEOF */ + +static uae_s32 ARCunsqueeze(struct zfile *in, struct zfile *out, struct rledata *rled) +{ + uae_s32 err = 0; + uae_s32 i, numnodes; + uae_s16 *node; + struct fout io; + + io.zf = in; + io.xio_BitBuf = 0; + io.xio_BitNum = 0; + io.err = 0; + + if((node = (uae_s16 *) xcalloc(uae_s16, 2*ARCSQNUMVALS))) + { + numnodes = xadIOGetBitsLow(&io, 16); + + if(numnodes < 0 || numnodes >= ARCSQNUMVALS) + err = XADERR_DECRUNCH; + else + { /* initialize for possible empty tree (SPEOF only) */ + node[0] = node[1] = -(ARCSQSPEOF + 1); + + numnodes *= 2; i = 0; + while(i < numnodes && !io.err) /* get decoding tree from file */ + { + node[i++] = xadIOGetBitsLow(&io, 16); + node[i++] = xadIOGetBitsLow(&io, 16); + } + + do + { + /* follow bit stream in tree to a leaf */ + i = 0; + while(i >= 0 && !io.err) + i = node[2*i + xadIOGetBitsLow(&io, 1)]; + + i = -(i + 1); /* decode fake node index to original data value */ + + if(i != ARCSQSPEOF) + putrle (i, out, rled); + } while(i != ARCSQSPEOF); + } + xfree(node); + } + else + err = XADERR_NOMEMORY; + + return err; +} + + + + +#define UCOMPMAXCODE(n) (((uae_u32) 1 << (n)) - 1) +#define UCOMPBITS 16 +#define UCOMPSTACKSIZE 8000 +#define UCOMPFIRST 257 /* first free entry */ +#define UCOMPCLEAR 256 /* table clear output code */ +#define UCOMPINIT_BITS 9 /* initial number of bits/code */ +#define UCOMPBIT_MASK 0x1f +#define UCOMPBLOCK_MASK 0x80 + +struct UCompData { + uae_s16 clear_flg; + uae_u16 n_bits; /* number of bits/code */ + uae_u16 maxbits; /* user settable max # bits/code */ + uae_u32 maxcode; /* maximum code, given n_bits */ + uae_u32 maxmaxcode; + uae_s32 free_ent; + uae_s32 offset; + uae_s32 size; + uae_u16 *tab_prefixof; + uae_u8 *tab_suffixof; + uae_u8 stack[UCOMPSTACKSIZE]; + uae_u8 buf[UCOMPBITS]; + int insize; + struct rledata *rled; +}; + + +/* Read one code from input. If EOF, return -1. */ +static uae_s32 UCompgetcode(struct zfile *in, struct UCompData *cd) +{ + uae_s32 code, r_off, bits; + uae_u8 *bp = cd->buf; + + if(cd->clear_flg > 0 || cd->offset >= cd->size || cd->free_ent > cd->maxcode) + { + /* + * If the next entry will be too big for the current code + * size, then we must increase the size. This implies reading + * a new buffer full, too. + */ + if(cd->free_ent > cd->maxcode) + { + if(++cd->n_bits == cd->maxbits) + cd->maxcode = cd->maxmaxcode; /* won't get any bigger now */ + else + cd->maxcode = UCOMPMAXCODE(cd->n_bits); + } + if(cd->clear_flg > 0) + { + cd->maxcode = UCOMPMAXCODE(cd->n_bits = UCOMPINIT_BITS); + cd->clear_flg = 0; + } + + /* This reads maximum n_bits characters into buf */ + cd->size = 0; + while(cd->size < cd->n_bits) { + int v; + if (cd->insize == 0) + break; + v = zfile_getc (in); + if (v == -1) + break; + cd->insize--; + cd->buf[cd->size++] = v; + } + if(cd->size <= 0) + return -1; + + cd->offset = 0; + /* Round size down to integral number of codes */ + cd->size = (cd->size << 3) - (cd->n_bits - 1); + } + + r_off = cd->offset; + bits = cd->n_bits; + + /* Get to the first byte. */ + bp += (r_off >> 3); + r_off &= 7; + + /* Get first part (low order bits) */ + code = (*bp++ >> r_off); + bits -= (8 - r_off); + r_off = 8 - r_off; /* now, offset into code word */ + + /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */ + if(bits >= 8) + { + code |= *bp++ << r_off; + r_off += 8; + bits -= 8; + } + + /* high order bits. */ + code |= (*bp & ((1<offset += cd->n_bits; + + return code; +} + +static uae_u32 xadIO_Compress(struct zfile *in, struct zfile *out, int insize, struct rledata *rled, uae_u8 bitinfo) +{ + int err = 0; + struct UCompData *cd; + + if((bitinfo & UCOMPBIT_MASK) < UCOMPINIT_BITS) + return XADERR_ILLEGALDATA; + + if((cd = xcalloc(struct UCompData, 1))) + { + int finchar, code, oldcode, incode, blockcomp; + uae_u8 *stackp, *stack, *stackend; + + stackp = stack = cd->stack; + stackend = stack + UCOMPSTACKSIZE; + cd->maxbits = bitinfo & UCOMPBIT_MASK; + blockcomp = bitinfo & UCOMPBLOCK_MASK; + cd->maxmaxcode = 1 << cd->maxbits; + cd->maxcode = UCOMPMAXCODE(cd->n_bits = UCOMPINIT_BITS); + cd->free_ent = blockcomp ? UCOMPFIRST : 256; + cd->insize = insize; + cd->rled = rled; + + if((cd->tab_prefixof = xcalloc(uae_u16, cd->maxmaxcode))) + { + if((cd->tab_suffixof = xcalloc(uae_u8, cd->maxmaxcode))) + { + /* Initialize the first 256 entries in the table. */ + for(code = 255; code >= 0; code--) + cd->tab_suffixof[code] = code; + + if((finchar = oldcode = UCompgetcode(in, cd)) == -1) + err = XADERR_DECRUNCH; + else + { + putrle (finchar, out, cd->rled); /* first code must be 8 bits = uae_u8 */ + + while((code = UCompgetcode(in, cd)) > -1) + { + if((code == UCOMPCLEAR) && blockcomp) + { + for(code = 255; code >= 0; code--) + cd->tab_prefixof[code] = 0; + cd->clear_flg = 1; + cd->free_ent = UCOMPFIRST - 1; + if((code = UCompgetcode(in, cd)) == -1) + break; /* O, untimely death! */ + } + incode = code; + + /* Special case for KwKwK string. */ + if(code >= cd->free_ent) + { + if(code > cd->free_ent) + { + err = XADERR_ILLEGALDATA; + break; + } + *stackp++ = finchar; + code = oldcode; + } + + /* Generate output characters in reverse order */ + while(stackp < stackend && code >= 256) + { + *stackp++ = cd->tab_suffixof[code]; + code = cd->tab_prefixof[code]; + } + if(stackp >= stackend) + { + err = XADERR_ILLEGALDATA; + break; + } + *(stackp++) = finchar = cd->tab_suffixof[code]; + + /* And put them out in forward order */ + do + { + putrle (*(--stackp), out, cd->rled); + } while(stackp > stack); + + /* Generate the new entry. */ + if((code = cd->free_ent) < cd->maxmaxcode) + { + cd->tab_prefixof[code] = (uae_u16) oldcode; + cd->tab_suffixof[code] = finchar; + cd->free_ent = code+1; + } + /* Remember previous code. */ + oldcode = incode; + } + } + xfree (cd->tab_suffixof); + } + else + err = XADERR_NOMEMORY; + xfree(cd->tab_prefixof); + } + else + err = XADERR_NOMEMORY; + xfree(cd); + } + else + err = XADERR_NOMEMORY; + + return err; +} + +static void MakeCRC16(uae_u16 *buf, uae_u16 ID) +{ + uae_u16 i, j, k; + + for(i = 0; i < 256; ++i) + { + k = i; + + for(j = 0; j < 8; ++j) + { + if(k & 1) + k = (k >> 1) ^ ID; + else + k >>= 1; + } + buf[i] = k; + } +} + +static uae_u16 wrpcrc16 (uae_u16 *tab, uae_u8 *buf, int len) +{ + uae_u16 crc = 0; + while (len-- > 0) + crc = tab[(crc ^ *buf++) & 0xFF] ^ (crc >> 8); + return crc; +} + +static int iswrp (uae_u8 *data) +{ + if(data[0] == 'W' && data[1] == 'a' && data[2] == 'r' && data[3] == 'p' + && data[4] == ' ' && data[5] == 'v' && data[6] == '1' && data[7] == '.' + && data[8] == '1' && !data[9] && !data[18] && data[19] <= 3) + return 1; + return 0; +} + +#define COMPBUF 30000 + +struct zfile *unwarp(struct zfile *zf) +{ + int err = 0; + uae_u8 buf[26] = { 0 }; + int algo, side, track; + int pos, dstpos, olddstpos; + uae_u16 crc; + uae_u32 size; + struct zfile *nf = NULL, *tmpf = NULL; + uae_u8 *zero, *data; + int outsize = 11 * 512; + int outsize2 = 11 * (512 + 16); + struct rledata rled; + uae_u16 wrpcrc16table[256]; + + MakeCRC16 (wrpcrc16table, 0xa001); + + zero = xcalloc (uae_u8, outsize2); + olddstpos = 0; + for (;;) { + if (zfile_fread (buf, sizeof buf, 1, zf) == 0) + break; + if (!iswrp (buf)) + break; + if (!nf) { + nf = zfile_fopen_empty (zf, L"zipped.wrp", 1760 * 512); + tmpf = zfile_fopen_empty (zf, L"tmp", outsize2); + } + track = (buf[10] << 8) | buf[11]; + algo = buf[19]; + side = -1; + if (!memcmp (buf + 12, "BOT\0", 4)) + side = 1; + if (!memcmp (buf + 12, "TOP\0", 4)) + side = 0; + crc = (buf[20] << 8) | buf[21]; + pos = zfile_ftell (zf); + dstpos = -1; + if (side >= 0 && track >= 0 && track <= 79) + dstpos = track * 22 * 512 + (side * 11 * 512); + zfile_fseek (tmpf, 0, SEEK_SET); + zfile_fwrite (zero, outsize2, 1, tmpf); + zfile_fseek (tmpf, 0, SEEK_SET); + size = (buf[22] << 24) | (buf[23] << 16) | (buf[24] << 8) | buf[25]; + err = 0; + memset (&rled, 0, sizeof rled); + + switch (algo) + { + case 1: + if (zfile_getc (zf) != 12) + err = XADERR_ILLEGALDATA; + else + err = xadIO_Compress (zf, tmpf, size - 1, &rled, 12 | UCOMPBLOCK_MASK); + break; + case 2: + err = ARCunsqueeze (zf, tmpf, &rled); + break; + case 0: + case 3: + { + int i; + for (i = 0; i < size; i++) { + uae_u8 v = zfile_getc (zf); + putrle (v, tmpf, algo == 3 ? &rled : NULL); + } + } + break; + default: + write_log (L"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); + } 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); + xfree (data); + } + if (dstpos >= 0) { + zfile_fseek (nf, dstpos, SEEK_SET); + data = zfile_getdata (tmpf, 0, outsize); + zfile_fwrite (data, outsize, 1, nf); + } + zfile_fseek (zf, pos + size, SEEK_SET); + } +end: + xfree (zero); + zfile_fclose (tmpf); + if (nf) { + zfile_fclose (zf); + zf = nf; + } + return zf; +} + diff --git a/archivers/xfd/main.c b/archivers/xfd/main.cpp similarity index 100% rename from archivers/xfd/main.c rename to archivers/xfd/main.cpp diff --git a/archivers/xfd/xfd.c b/archivers/xfd/xfd.cpp similarity index 100% rename from archivers/xfd/xfd.c rename to archivers/xfd/xfd.cpp diff --git a/archivers/zip/unzip.c b/archivers/zip/unzip.cpp similarity index 91% rename from archivers/zip/unzip.c rename to archivers/zip/unzip.cpp index 7f874394..6c28b8d6 100644 --- a/archivers/zip/unzip.c +++ b/archivers/zip/unzip.cpp @@ -137,9 +137,7 @@ typedef struct */ -local int unzlocal_getByte(fin,pi) - struct zfile *fin; - int *pi; +local int unzlocal_getByte(struct zfile *fin,int *pi) { unsigned char c; int err = zfile_fread(&c, 1, 1, fin); @@ -158,9 +156,7 @@ local int unzlocal_getByte(fin,pi) /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ -local int unzlocal_getShort (fin,pX) - struct zfile* fin; - uLong *pX; +local int unzlocal_getShort (struct zfile *fin,uLong *pX) { uLong x ; int i; @@ -180,9 +176,7 @@ local int unzlocal_getShort (fin,pX) return err; } -local int unzlocal_getLong (fin,pX) - struct zfile* fin; - uLong *pX; +local int unzlocal_getLong (struct zfile *fin, uLong *pX) { uLong x ; int i; @@ -212,9 +206,7 @@ local int unzlocal_getLong (fin,pX) /* My own strcmpi / strcasecmp */ -local int strcmpcasenosensitive_internal (fileName1,fileName2) - const char* fileName1; - const char* fileName2; +local int strcmpcasenosensitive_internal (const char *fileName1, const char *fileName2) { for (;;) { @@ -255,10 +247,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2) (like 1 on Unix, 2 on Windows) */ -extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) - const char* fileName1; - const char* fileName2; - int iCaseSensitivity; +extern int ZEXPORT unzStringFileNameCompare (const char*fileName1, const char*fileName2, int iCaseSensitivity) { if (iCaseSensitivity==0) iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; @@ -275,8 +264,7 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit Locate the Central directory of a zipfile (at the end, just before the global comment) */ -local uLong unzlocal_SearchCentralDir(fin) - struct zfile *fin; +local uLong unzlocal_SearchCentralDir(struct zfile *fin) { unsigned char* buf; uLong uSizeFile; @@ -340,8 +328,7 @@ local uLong unzlocal_SearchCentralDir(fin) Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ -extern unzFile ZEXPORT unzOpen (fin) - struct zfile *fin; +extern unzFile ZEXPORT unzOpen (struct zfile *fin) { unz_s us; unz_s *s; @@ -431,8 +418,7 @@ extern unzFile ZEXPORT unzOpen (fin) If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzClose (file) - unzFile file; +extern int ZEXPORT unzClose (unzFile file) { unz_s* s; if (file==NULL) @@ -451,9 +437,7 @@ extern int ZEXPORT unzClose (file) Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) - unzFile file; - unz_global_info *pglobal_info; +extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info) { unz_s* s; if (file==NULL) @@ -467,9 +451,7 @@ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) /* Translate date/time from Dos format to tm_unz (readable more easilty) */ -local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) - uLong ulDosDate; - tm_unz* ptm; +local void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz *ptm) { uLong uDate; uDate = (uLong)(ulDosDate>>16); @@ -496,21 +478,12 @@ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, char *szComment, uLong commentBufferSize)); -local int unzlocal_GetCurrentFileInfoInternal (file, - pfile_info, - pfile_info_internal, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - unz_file_info_internal *pfile_info_internal; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; +local int unzlocal_GetCurrentFileInfoInternal (unzFile file, + unz_file_info *pfile_info, + unz_file_info_internal *pfile_info_internal, + char *szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char *szComment, uLong commentBufferSize) { unz_s* s; unz_file_info file_info; @@ -661,19 +634,11 @@ local int unzlocal_GetCurrentFileInfoInternal (file, No preparation of the structure is needed return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetCurrentFileInfo (file, - pfile_info, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; +extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, + unz_file_info *pfile_info, + char *szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char *szComment, uLong commentBufferSize) { return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, szFileName,fileNameBufferSize, @@ -685,8 +650,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (file, Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ -extern int ZEXPORT unzGoToFirstFile (file) - unzFile file; +extern int ZEXPORT unzGoToFirstFile (unzFile file) { int err=UNZ_OK; unz_s* s; @@ -708,8 +672,7 @@ extern int ZEXPORT unzGoToFirstFile (file) return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ -extern int ZEXPORT unzGoToNextFile (file) - unzFile file; +extern int ZEXPORT unzGoToNextFile (unzFile file) { unz_s* s; int err; @@ -741,10 +704,7 @@ extern int ZEXPORT unzGoToNextFile (file) UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ -extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) - unzFile file; - const char *szFileName; - int iCaseSensitivity; +extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) { unz_s* s; int err; @@ -794,13 +754,9 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) store in *piSizeVar the size of extra info in local header (filename and size of extra field data) */ -local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, - poffset_local_extrafield, - psize_local_extrafield) - unz_s* s; - uInt* piSizeVar; - uLong *poffset_local_extrafield; - uInt *psize_local_extrafield; +local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s, uInt *piSizeVar, + uLong *poffset_local_extrafield, + uInt *psize_local_extrafield) { uLong uMagic,uData,uFlags; uLong size_filename; @@ -884,8 +840,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ -extern int ZEXPORT unzOpenCurrentFile (file) - unzFile file; +extern int ZEXPORT unzOpenCurrentFile (unzFile file) { int err=UNZ_OK; int Store; @@ -985,10 +940,7 @@ extern int ZEXPORT unzOpenCurrentFile (file) return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ -extern int ZEXPORT unzReadCurrentFile (file, buf, len) - unzFile file; - voidp buf; - unsigned len; +extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned int len) { int err=UNZ_OK; uInt iRead = 0; @@ -1112,8 +1064,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) /* Give the current position in uncompressed data */ -extern z_off_t ZEXPORT unztell (file) - unzFile file; +extern z_off_t ZEXPORT unztell (unzFile file) { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; @@ -1132,8 +1083,7 @@ extern z_off_t ZEXPORT unztell (file) /* return 1 if the end of file was reached, 0 elsewhere */ -extern int ZEXPORT unzeof (file) - unzFile file; +extern int ZEXPORT unzeof (unzFile file) { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; @@ -1165,10 +1115,7 @@ extern int ZEXPORT unzeof (file) the return value is the number of bytes copied in buf, or (if <0) the error code */ -extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) - unzFile file; - voidp buf; - unsigned len; +extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned int len) { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; @@ -1212,8 +1159,7 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) Close the file in zip opened with unzipOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ -extern int ZEXPORT unzCloseCurrentFile (file) - unzFile file; +extern int ZEXPORT unzCloseCurrentFile (unzFile file) { int err=UNZ_OK; @@ -1254,10 +1200,7 @@ extern int ZEXPORT unzCloseCurrentFile (file) uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ -extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) - unzFile file; - char *szComment; - uLong uSizeBuf; +extern int ZEXPORT unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf) { int err=UNZ_OK; unz_s* s; diff --git a/audio.c b/audio.cpp similarity index 99% rename from audio.c rename to audio.cpp index 589685ea..13c3169b 100644 --- a/audio.c +++ b/audio.cpp @@ -68,7 +68,7 @@ static int debugchannel (int ch) * entries so that CPU updates during minimum period can be played back. */ #define SINC_QUEUE_LENGTH (SINC_QUEUE_MAX_AGE / 16 + 2) -#include "sinctable.c" +#include "sinctable.cpp" typedef struct { int age, output; @@ -240,7 +240,7 @@ static void do_samplerip (struct audio_channel_data *adp) /* replace old identical but shorter sample */ if (len > rs->len && !memcmp (rs->sample, smp, rs->len)) { xfree (rs->sample); - rs->sample = xmalloc (len); + rs->sample = xmalloc (uae_u8, len); memcpy (rs->sample, smp, len); write_log (L"SAMPLERIPPER: replaced sample %d (%d -> %d)\n", cnt, rs->len, len); rs->len = len; @@ -256,14 +256,14 @@ static void do_samplerip (struct audio_channel_data *adp) } if (rs || cnt > 100) return; - rs = xmalloc (sizeof(struct ripped_sample)); + rs = xmalloc (struct ripped_sample ,1); if (prev) prev->next = rs; else ripped_samples = rs; rs->len = len; rs->per = adp->per / CYCLE_UNIT; - rs->sample = xmalloc (len); + rs->sample = xmalloc (uae_u8, len); memcpy (rs->sample, smp, len); rs->next = NULL; rs->changed = 1; @@ -1589,8 +1589,6 @@ void audio_evhandler (void) schedule_audio (); } -uae_u16 dmacon; - void audio_hsync (int hpos) { int nr, handle; diff --git a/autoconf.c b/autoconf.cpp similarity index 99% rename from autoconf.c rename to autoconf.cpp index 31fa5e16..86af5d93 100644 --- a/autoconf.c +++ b/autoconf.cpp @@ -202,7 +202,7 @@ static uae_u32 REGPARAM2 getchipmemsize (TrapContext *context) static uae_u32 REGPARAM2 uae_puts (TrapContext *context) { - puts ((uae_u8*)get_real_address (m68k_areg (regs, 0))); + puts ((char*)get_real_address (m68k_areg (regs, 0))); return 0; } diff --git a/blitops.c b/blitops.cpp similarity index 100% rename from blitops.c rename to blitops.cpp diff --git a/blitter.c b/blitter.cpp similarity index 99% rename from blitter.c rename to blitter.cpp index db251073..628ef15e 100644 --- a/blitter.c +++ b/blitter.cpp @@ -1517,7 +1517,7 @@ uae_u8 *save_blitter (int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = xmalloc (16); + dstbak = dst = xmalloc (uae_u8, 16); save_u32 (((bltstate != BLT_done) ? 0 : 1) | forced | 4); *len = dst - dstbak; return dstbak; diff --git a/blkdev.c b/blkdev.cpp similarity index 98% rename from blkdev.c rename to blkdev.cpp index a51893e5..d714127d 100644 --- a/blkdev.c +++ b/blkdev.cpp @@ -294,7 +294,7 @@ void scsi_atapi_fixup_pre (uae_u8 *scsi_cmd, int *len, uae_u8 **datap, int *data scsi_cmd[9] = scsi_cmd[5]; scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[4] = scsi_cmd[5] = scsi_cmd[6] = 0; *len = 10; - p = (uae_u8*)xmalloc (8 + datalen + 4); + p = xmalloc (uae_u8, 8 + datalen + 4); if (datalen > 4) memcpy (p + 8, data + 4, datalen - 4); p[0] = 0; @@ -313,7 +313,7 @@ void scsi_atapi_fixup_pre (uae_u8 *scsi_cmd, int *len, uae_u8 **datap, int *data scsi_cmd[3] = scsi_cmd[4] = scsi_cmd[5] = scsi_cmd[6] = 0; if (l > 8) datalen += 4; - *datap = (uae_u8*)xmalloc (datalen); + *datap = xmalloc (uae_u8, datalen); *len = 10; *parm = MODE_SENSE_10; } @@ -445,7 +445,7 @@ uae_u8 *save_cd (int num, int *len) if (!currprefs.cdimagefile[0]) return NULL; - dstbak = dst = xmalloc (4 + 256); + dstbak = dst = xmalloc (uae_u8, 4 + 256); save_u32 (4); save_string (currprefs.cdimagefile); *len = dst - dstbak; diff --git a/blkdev_cdimage.c b/blkdev_cdimage.cpp similarity index 99% rename from blkdev_cdimage.c rename to blkdev_cdimage.cpp index c28d3e9a..7381d09b 100644 --- a/blkdev_cdimage.c +++ b/blkdev_cdimage.cpp @@ -282,7 +282,7 @@ static uae_u8 *mp3decoder_get (struct zfile *zf, int maxsize) return NULL; } zfile_fseek (zf, 0, SEEK_SET); - outbuf = xcalloc (maxsize, 1); + outbuf = xcalloc (uae_u8, maxsize); for (;;) { int count = zfile_fread (mp3buf, 1, MP3_BLOCK_SIZE, zf); if (count != MP3_BLOCK_SIZE) @@ -361,7 +361,7 @@ static void *cdda_play_func (void *v) Sleep (10); oldplay = -1; - p = xmalloc (2 * num_sectors * 4096); + p = xmalloc (uae_u8, 2 * num_sectors * 4096); px[0] = p; px[1] = p + num_sectors * 4096; bufon[0] = bufon[1] = 0; @@ -375,7 +375,7 @@ static void *cdda_play_func (void *v) for (i = 0; i < 2; i++) { memset (&whdr[i], 0, sizeof (WAVEHDR)); whdr[i].dwBufferLength = 2352 * num_sectors; - whdr[i].lpData = px[i]; + whdr[i].lpData = (LPSTR)px[i]; mmr = waveOutPrepareHeader (cdda_wavehandle, &whdr[i], sizeof (WAVEHDR)); if (mmr != MMSYSERR_NOERROR) { write_log (L"CDDA: waveOutPrepareHeader %d:%d\n", i, mmr); diff --git a/bsdsocket.c b/bsdsocket.cpp similarity index 98% rename from bsdsocket.c rename to bsdsocket.cpp index 0d4b8129..e1406280 100644 --- a/bsdsocket.c +++ b/bsdsocket.cpp @@ -26,6 +26,7 @@ #ifdef BSDSOCKET +struct socketbase *socketbases; static uae_u32 SockLibBase; #define SOCKPOOLSIZE 128 @@ -82,7 +83,7 @@ uae_u32 addmem (uae_u32 * dst, const uae_char *src, int len) if (!src) return 0; - memcpyha_safe (*dst, src, len); + memcpyha_safe (*dst, (uae_u8*)src, len); (*dst) += len; return res; @@ -216,7 +217,7 @@ SOCKET_TYPE getsock (SB, int sd) ot1 = get_long (sb1->ownertask + 10); if (!addr_valid (L"getsock4", ot1, 1)) break; - if (strcmp(get_real_address (ot1), get_real_address (ot)) == 0) { + if (strcmp((char*)get_real_address (ot1), (char*)get_real_address (ot)) == 0) { // Task with same name already exists -> use same dtable if (sb1->dtable[sd - 1] != INVALID_SOCKET) return sb1->dtable[sd - 1]; @@ -372,7 +373,7 @@ static struct socketbase *alloc_socketbase (TrapContext *context) SB; int i; - if ((sb = (struct socketbase*)calloc (sizeof (struct socketbase), 1)) != NULL) { + if ((sb = xcalloc (struct socketbase, 1)) != NULL) { sb->ownertask = gettask (context); m68k_dreg (regs, 0) = -1; @@ -691,7 +692,7 @@ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize) { int *newdtable; int *newftable; - int *newmtable; + unsigned int *newmtable; int i; if (newSize < sb->dtablesize) { @@ -699,9 +700,9 @@ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize) return 0; } - newdtable = (int *)calloc(newSize, sizeof(*sb->dtable)); - newftable = (int *)calloc(newSize, sizeof(*sb->ftable)); - newmtable = (int *)calloc(newSize, sizeof(*sb->mtable)); + newdtable = xcalloc (int, newSize); + newftable = xcalloc (int, newSize); + newmtable = xcalloc (unsigned int, newSize); if (newdtable == NULL || newftable == NULL || newmtable == NULL) { sb->resultval = -1; @@ -712,9 +713,9 @@ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize) return -1; } - memcpy(newdtable, sb->dtable, sb->dtablesize * sizeof(*sb->dtable)); - memcpy(newftable, sb->ftable, sb->dtablesize * sizeof(*sb->ftable)); - memcpy(newmtable, sb->mtable, sb->dtablesize * sizeof(*sb->mtable)); + memcpy (newdtable, sb->dtable, sb->dtablesize * sizeof(*sb->dtable)); + memcpy (newftable, sb->ftable, sb->dtablesize * sizeof(*sb->ftable)); + memcpy (newmtable, sb->mtable, sb->dtablesize * sizeof(*sb->mtable)); for (i = sb->dtablesize + 1; i < newSize; i++) newdtable[i] = -1; @@ -1228,11 +1229,11 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) break; case SBTC_ERRNO: BSDTRACE ((L"SBTC_ERRNO),%d", currval)); - tagcopy (currtag, currval, tagptr, &sb->sb_errno); + tagcopy (currtag, currval, tagptr, (uae_u32*)&sb->sb_errno); break; case SBTC_HERRNO: BSDTRACE ((L"SBTC_HERRNO),%d", currval)); - tagcopy (currtag, currval, tagptr, &sb->sb_herrno); + tagcopy (currtag, currval, tagptr, (uae_u32*)&sb->sb_herrno); break; case SBTC_DTABLESIZE: BSDTRACE ((L"SBTC_DTABLESIZE),0x%lx", currval)); @@ -1522,7 +1523,7 @@ void bsdlib_install (void) int i; if (!sockdata) { - sockdata = xcalloc (sizeof (struct sockd), 1); + sockdata = xcalloc (struct sockd, 1); for (i = 0; i < SOCKPOOLSIZE; i++) sockdata->sockpoolids[i] = UNIQUE_ID; } diff --git a/build68k.c b/build68k.cpp similarity index 100% rename from build68k.c rename to build68k.cpp diff --git a/catweasel.c b/catweasel.cpp similarity index 99% rename from catweasel.c rename to catweasel.cpp index 5bdea34c..a05f7e7c 100644 --- a/catweasel.c +++ b/catweasel.cpp @@ -311,7 +311,7 @@ void catweasel_do_bput (uaecptr addr, uae_u32 b) //write_log (L"P %02X %02X %d\n", (uae_u8)addr, (uae_u8)b, did_read); } -#include "core.cw4.c" +#include "core.cw4.cpp" static int cw_config_done (void) { @@ -522,7 +522,8 @@ static int detected; int catweasel_init(void) { TCHAR name[32], tmp[1000], *s; - int i, len; + int i; + DWORD len; uae_u8 buffer[10000]; uae_u32 model, base; int detect = 0; @@ -589,7 +590,7 @@ int catweasel_init(void) write_log (L"CW: CW_GET_VERSION failed %d\n", GetLastError ()); goto fail; } - s = au (buffer); + s = au ((char*)buffer); write_log (L"CW driver version string '%s'\n", s); xfree (s); if (!DeviceIoControl (handle, CW_GET_HWVERSION, 0, 0, buffer, sizeof (buffer), &len, 0)) { diff --git a/cd32_fmv.c b/cd32_fmv.cpp similarity index 99% rename from cd32_fmv.c rename to cd32_fmv.cpp index f475af9e..c7027939 100644 --- a/cd32_fmv.c +++ b/cd32_fmv.cpp @@ -146,7 +146,7 @@ static void REGPARAM2 fmv_wput (uaecptr addr, uae_u32 w) fmv_bput2 (addr + 1, w); } -static addrbank fmv_bank; +extern addrbank fmv_bank; static void REGPARAM2 fmv_bput (uaecptr addr, uae_u32 b) { diff --git a/cdrom.c b/cdrom.cpp similarity index 100% rename from cdrom.c rename to cdrom.cpp diff --git a/cdtv.c b/cdtv.cpp similarity index 100% rename from cdtv.c rename to cdtv.cpp diff --git a/cfgfile.c b/cfgfile.cpp similarity index 99% rename from cfgfile.c rename to cfgfile.cpp index 0db8c178..804a6747 100644 --- a/cfgfile.c +++ b/cfgfile.cpp @@ -213,7 +213,7 @@ TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *f /* @@@ use strcasecmp for some targets. */ if (_tcslen (path) > 0 && _tcsncmp (file, path, _tcslen (path)) == 0) { int l; - TCHAR *p = xmalloc ((_tcslen (file) + _tcslen (subst) + 2) * sizeof (TCHAR)); + TCHAR *p = xmalloc (TCHAR, _tcslen (file) + _tcslen (subst) + 2); _tcscpy (p, subst); l = _tcslen (p); while (l > 0 && p[l - 1] == '/') @@ -245,11 +245,11 @@ static size_t cfg_write (void *b, struct zfile *z) size_t v; if (unicode_config) { TCHAR lf = 10; - v = zfile_fwrite (b, _tcslen (b), sizeof (TCHAR), z); + v = zfile_fwrite (b, _tcslen ((TCHAR*)b), sizeof (TCHAR), z); zfile_fwrite (&lf, 1, 1, z); } else { char lf = 10; - char *s = ua (b); + char *s = ua ((TCHAR*)b); v = zfile_fwrite (s, strlen (s), 1, z); zfile_fwrite (&lf, 1, 1, z); xfree (s); @@ -854,7 +854,7 @@ int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, i return 1; } -int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale) +int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, unsigned int *location, int scale) { int base = 10; TCHAR *endptr; @@ -879,6 +879,17 @@ int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, } return 1; } +int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale) +{ + unsigned int v = 0; + int r = cfgfile_intval (option, value, name, &v, scale); + if (!r) + return 0; + *location = (int)v; + return r; +} + + int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more) { @@ -1405,7 +1416,7 @@ static void decode_rom_ident (TCHAR *romfile, int maxlen, TCHAR *ident) if (!ident[0]) return; - romtxt = malloc (10000 * sizeof (TCHAR)); + romtxt = xmalloc (TCHAR, 10000); romtxt[0] = 0; for (round = 0; round < 2; round++) { ver = rev = subver = subrev = -1; @@ -1543,7 +1554,7 @@ struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index, static void parse_addmem (struct uae_prefs *p, TCHAR *buf, int num) { - uae_u32 size = 0, addr = 0; + int size = 0, addr = 0; if (!getintval2 (&buf, &addr, ',')) return; @@ -2131,7 +2142,7 @@ static void cfgfile_parse_separated_line (struct uae_prefs *p, TCHAR *line1b, TC if (sl->option && !strcasecmp (line1b, sl->option)) break; } if (!sl) { - struct strlist *u = xcalloc (sizeof (struct strlist), 1); + struct strlist *u = xcalloc (struct strlist, 1); u->option = my_strdup (line3b); u->value = my_strdup (line4b); u->next = p->all_lines; @@ -2335,7 +2346,7 @@ int cfgfile_save (struct uae_prefs *p, const TCHAR *filename, int type) int cfgfile_get_description (const TCHAR *filename, TCHAR *description, TCHAR *hostlink, TCHAR *hardwarelink, int *type) { int result = 0; - struct uae_prefs *p = xmalloc (sizeof (struct uae_prefs)); + struct uae_prefs *p = xmalloc (struct uae_prefs, 1); p->description[0] = 0; p->config_host_path[0] = 0; @@ -2586,7 +2597,7 @@ static void parse_cpu_specs (struct uae_prefs *p, const TCHAR *spec) /* Returns the number of args used up (0 or 1). */ int parse_cmdline_option (struct uae_prefs *p, TCHAR c, const TCHAR *arg) { - struct strlist *u = xcalloc (sizeof (struct strlist), 1); + struct strlist *u = xcalloc (struct strlist, 1); const TCHAR arg_required[] = L"0123rKpImWSAJwNCZUFcblOdHRv"; if (_tcschr (arg_required, c) && ! arg) { @@ -2594,7 +2605,7 @@ int parse_cmdline_option (struct uae_prefs *p, TCHAR c, const TCHAR *arg) return 0; } - u->option = xmalloc (2 * sizeof (TCHAR)); + u->option = xmalloc (TCHAR, 2); u->option[0] = c; u->option[1] = 0; u->value = my_strdup (arg); @@ -2727,7 +2738,7 @@ void cfgfile_addcfgparam (TCHAR *line) } if (!cfgfile_separate_line (line, line1b, line2b)) return; - u = xcalloc (sizeof (struct strlist), 1); + u = xcalloc (struct strlist, 1); u->option = my_strdup (line1b); u->value = my_strdup (line2b); u->next = temp_lines; @@ -2768,7 +2779,7 @@ static int cfgfile_handle_custom_event (TCHAR *custom, int mode) } nextp = NULL; - tmp = p = xcalloc (_tcslen (custom) + 2, 1); + tmp = p = xcalloc (TCHAR, _tcslen (custom) + 2); _tcscpy (tmp, custom); while (p && *p) { if (*p == '\"') { @@ -3022,13 +3033,13 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u while (get_byte (parms + size) != 0) size++; } - parms_p = xmalloc (size + 1); + parms_p = xmalloc (uae_char, size + 1); if (!parms_p) { ret = 10; goto end; } if (out) { - out_p = xmalloc ((outsize + 1) * sizeof (TCHAR)); + out_p = xmalloc (TCHAR, outsize + 1); if (!out_p) { ret = 10; goto end; @@ -3100,10 +3111,10 @@ uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen) uae_u8 *restore_configuration (uae_u8 *src) { - TCHAR *s = au (src); + TCHAR *s = au ((char*)src); //write_log (s); xfree (s); - src += strlen (src) + 1; + src += strlen ((char*)src) + 1; return src; } @@ -3113,7 +3124,7 @@ uae_u8 *save_configuration (int *len) uae_u8 *dstbak, *dst, *p; int index = -1; - dstbak = dst = malloc (tmpsize * sizeof (TCHAR)); + dstbak = dst = xmalloc (uae_u8, tmpsize); p = dst; for (;;) { TCHAR tmpout[256]; @@ -3126,10 +3137,10 @@ uae_u8 *save_configuration (int *len) if (!_tcsncmp (tmpout, L"input.", 6)) continue; out = ua (tmpout); - strcpy (p, out); + strcpy ((char*)p, out); xfree (out); - strcat (p, "\n"); - p += strlen (p); + strcat ((char*)p, "\n"); + p += strlen ((char*)p); if (p - dstbak >= tmpsize - sizeof (tmpout)) break; } diff --git a/cia.c b/cia.cpp similarity index 99% rename from cia.c rename to cia.cpp index 08a11d65..49a419c3 100644 --- a/cia.c +++ b/cia.cpp @@ -1232,7 +1232,7 @@ addrbank cia_bank = { }; -STATIC_INLINE isgayle (void) +STATIC_INLINE int isgayle (void) { return (currprefs.cs_ide == IDE_A600A1200 || currprefs.cs_pcmcia); } diff --git a/consolehook.c b/consolehook.cpp similarity index 96% rename from consolehook.c rename to consolehook.cpp index 9bf747ce..e503e1cc 100644 --- a/consolehook.c +++ b/consolehook.cpp @@ -90,11 +90,11 @@ uaecptr consolehook_beginio (uaecptr request) if (cmd == CMD_WRITE) { TCHAR *buf; - const char *src = get_real_address (io_data); + const char *src = (char*)get_real_address (io_data); int len = io_length; if (io_length == -1) len = strlen (src); - buf = xmalloc ((len + 1) * sizeof (TCHAR)); + buf = xmalloc (TCHAR, len + 1); au_copy (buf, len, src); buf[len] = 0; f_out (L"%s", buf); diff --git a/core.cw4.c b/core.cw4.cpp similarity index 100% rename from core.cw4.c rename to core.cw4.cpp diff --git a/cpummu.c b/cpummu.cpp similarity index 100% rename from cpummu.c rename to cpummu.cpp diff --git a/cpuopti.c b/cpuopti.cpp similarity index 100% rename from cpuopti.c rename to cpuopti.cpp diff --git a/crc32.c b/crc32.cpp similarity index 96% rename from crc32.c rename to crc32.cpp index a82fd9d6..f0c68164 100644 --- a/crc32.c +++ b/crc32.cpp @@ -30,8 +30,9 @@ uae_u32 get_crc32_val (uae_u8 v, uae_u32 crc) crc = crc_table32[(crc ^ v) & 0xff] ^ (crc >> 8); return crc ^ 0xffffffff; } -uae_u32 get_crc32 (uae_u8 *buf, int len) +uae_u32 get_crc32 (void *vbuf, int len) { + uae_u8 *buf = (uae_u8*)vbuf; uae_u32 crc; if (!crc_table32[1]) make_crc_table(); @@ -40,8 +41,9 @@ uae_u32 get_crc32 (uae_u8 *buf, int len) crc = crc_table32[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8); return crc ^ 0xffffffff; } -uae_u16 get_crc16 (uae_u8 *buf, int len) +uae_u16 get_crc16 (void *vbuf, int len) { + uae_u8 *buf = (uae_u8*)vbuf; uae_u16 crc; if (!crc_table32[1]) make_crc_table(); @@ -327,16 +329,19 @@ static void sha1_finish( sha1_context *ctx, unsigned char output[20] ) PUT_UINT32_BE( ctx->state[4], output, 16 ); } -void get_sha1 (uae_u8 *input, int len, uae_u8 *out) +void get_sha1 (void *vinput, int len, void *vout) { + uae_u8 *input = (uae_u8*)vinput; + uae_u8 *out = (uae_u8*)vout; sha1_context ctx; sha1_starts( &ctx ); sha1_update( &ctx, input, len ); sha1_finish( &ctx, out ); } -const TCHAR *get_sha1_txt (uae_u8 *input, int len) +const TCHAR *get_sha1_txt (void *vinput, int len) { + uae_u8 *input = (uae_u8*)vinput; static TCHAR outtxt[SHA1_SIZE * 2 + 1]; uae_u8 out[SHA1_SIZE]; int i; diff --git a/custom.c b/custom.cpp similarity index 99% rename from custom.c rename to custom.cpp index 35e6c007..19dfef55 100644 --- a/custom.c +++ b/custom.cpp @@ -243,7 +243,6 @@ static unsigned int diwstrt, diwstop, diwhigh; static int diwhigh_written; static unsigned int ddfstrt, ddfstop, ddfstrt_old_hpos; static int ddf_change, badmode, diw_change; -static int fmode; static int bplcon1_hpos; /* The display and data fetch windows */ @@ -441,7 +440,7 @@ STATIC_INLINE void setclr (uae_u16 *p, uae_u16 val) *p &= ~val; } -STATIC_INLINE alloc_cycle (int hpos, int type) +STATIC_INLINE void alloc_cycle (int hpos, int type) { #ifdef CPUEMU_12 #if 0 @@ -455,7 +454,7 @@ STATIC_INLINE alloc_cycle (int hpos, int type) cycle_line[hpos] = type; #endif } -STATIC_INLINE alloc_cycle_maybe (int hpos, int type) +STATIC_INLINE void alloc_cycle_maybe (int hpos, int type) { if (cycle_line[hpos] == 0) alloc_cycle (hpos, type); @@ -992,7 +991,7 @@ static void maybe_setup_fmodes (int hpos) } } -STATIC_INLINE maybe_check (int hpos) +STATIC_INLINE void maybe_check (int hpos) { if (bpldmasetuphpos > 0 && hpos >= bpldmasetuphpos) maybe_setup_fmodes (hpos); @@ -1599,8 +1598,10 @@ STATIC_INLINE int one_fetch_cycle_0 (int pos, int ddfstop_to_test, int dma, int finish_final_fetch (pos, fm); return 1; } - if (plf_state >= plf_passed_stop) - plf_state++; + if (plf_state == plf_passed_stop) + plf_state = plf_passed_stop2; + else if (plf_state == plf_passed_stop2) + plf_state = plf_end; } maybe_check (pos); @@ -2710,12 +2711,7 @@ void compute_vsynctime (void) else vsynctime = vsynctime_orig = syncbase / fake_vblank_hz; if (!picasso_on) { -#ifdef OPENGL - OGL_refresh (); -#endif -#ifdef D3D - D3D_refresh (); -#endif + updatedisplayarea (); } if (currprefs.produce_sound > 1) update_sound (fake_vblank_hz, (bplcon0 & 4) ? -1 : lof, islinetoggle ()); @@ -3401,7 +3397,7 @@ int intlev (void) return -1; } -#define INT_PROCESSING_DELAY 1 +#define INT_PROCESSING_DELAY 3 * CYCLE_UNIT STATIC_INLINE int use_eventmode (uae_u16 v) { if (!currprefs.cpu_cycle_exact) @@ -3450,7 +3446,7 @@ static void INTENA (uae_u16 v) } if (use_eventmode (v)) - event2_newevent_xx (-1, INT_PROCESSING_DELAY * CYCLE_UNIT, intena, send_intena_do); + event2_newevent_xx (-1, INT_PROCESSING_DELAY, intena, send_intena_do); else send_intena_do (intena); #if 0 @@ -3472,7 +3468,7 @@ void INTREQ_0 (uae_u16 v) return; } if (use_eventmode (v)) - event2_newevent_xx (-1, INT_PROCESSING_DELAY * CYCLE_UNIT, intreq, send_intreq_do); + event2_newevent_xx (-1, INT_PROCESSING_DELAY, intreq, send_intreq_do); else send_intreq_do (intreq); } @@ -5871,8 +5867,8 @@ void customreset (int hardreset) void dumpcustom (void) { - console_out_f (L"DMACON: %x INTENA: %x INTREQ: %x VPOS: %x HPOS: %x\n", DMACONR (current_hpos ()), - (unsigned int)intena, (unsigned int)intreq, (unsigned int)vpos, (unsigned int)current_hpos()); + console_out_f (L"DMACON: %04x INTENA: %04x (%04x) INTREQ: %04x (%04x) VPOS: %x HPOS: %x\n", DMACONR (current_hpos ()), + intena, intena_internal, intreq, intreq_internal, vpos, current_hpos ()); console_out_f (L"COP1LC: %08lx, COP2LC: %08lx COPPTR: %08lx\n", (unsigned long)cop1lc, (unsigned long)cop2lc, cop_state.ip); console_out_f (L"DIWSTRT: %04x DIWSTOP: %04x DDFSTRT: %04x DDFSTOP: %04x\n", (unsigned int)diwstrt, (unsigned int)diwstop, (unsigned int)ddfstrt, (unsigned int)ddfstop); @@ -6612,7 +6608,7 @@ uae_u8 *save_custom (int *len, uae_u8 *dstptr, int full) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = malloc (8 + 256 * 2); + dstbak = dst = xmalloc (uae_u8, 8 + 256 * 2); SL (currprefs.chipset_mask); SW (0); /* 000 BLTDDAT */ @@ -6792,7 +6788,7 @@ uae_u8 *save_custom_agacolors (int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = xmalloc (256*4); + dstbak = dst = xmalloc (uae_u8, 256 * 4); for (i = 0; i < 256; i++) #ifdef AGA SL (current_colors.color_regs_aga[i] | (color_regs_aga_genlock[i] ? 0x80000000 : 0)); @@ -6828,7 +6824,7 @@ uae_u8 *save_custom_sprite(int num, int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = xmalloc (30); + dstbak = dst = xmalloc (uae_u8, 30); SL (spr[num].pt); /* 120-13E SPRxPT */ SW (sprpos[num]); /* 1x0 SPRxPOS */ SW (sprctl[num]); /* 1x2 SPRxPOS */ diff --git a/debug.c b/debug.cpp similarity index 98% rename from debug.c rename to debug.cpp index 31b7fae5..0650c648 100644 --- a/debug.c +++ b/debug.cpp @@ -838,8 +838,8 @@ struct dma_rec *record_dma (uae_u16 reg, uae_u16 dat, uae_u32 addr, int hpos, in struct dma_rec *dr; if (!dma_record[0]) { - dma_record[0] = xmalloc (NR_DMA_REC_HPOS * NR_DMA_REC_VPOS * sizeof (struct dma_rec)); - dma_record[1] = xmalloc (NR_DMA_REC_HPOS * NR_DMA_REC_VPOS * sizeof (struct dma_rec)); + dma_record[0] = xmalloc (struct dma_rec, NR_DMA_REC_HPOS * NR_DMA_REC_VPOS); + dma_record[1] = xmalloc (struct dma_rec, NR_DMA_REC_HPOS * NR_DMA_REC_VPOS); dma_record_toggle = 0; record_dma_reset (); } @@ -954,8 +954,8 @@ void record_copper (uaecptr addr, int hpos, int vpos) { int t = nr_cop_records[curr_cop_set]; if (!cop_record[0]) { - cop_record[0] = xmalloc (NR_COPPER_RECORDS * sizeof (struct cop_rec)); - cop_record[1] = xmalloc (NR_COPPER_RECORDS * sizeof (struct cop_rec)); + cop_record[0] = xmalloc (struct cop_rec, NR_COPPER_RECORDS); + cop_record[1] = xmalloc (struct cop_rec, NR_COPPER_RECORDS); } if (t < NR_COPPER_RECORDS) { cop_record[curr_cop_set][t].addr = addr; @@ -1111,7 +1111,7 @@ static int totaltrainers; static void clearcheater(void) { if (!trainerdata) - trainerdata = xmalloc(MAX_CHEAT_VIEW * sizeof (struct trainerstruct)); + trainerdata = xmalloc(struct trainerstruct, MAX_CHEAT_VIEW); memset(trainerdata, 0, sizeof (struct trainerstruct) * MAX_CHEAT_VIEW); totaltrainers = 0; } @@ -1194,7 +1194,7 @@ static void deepcheatsearch (TCHAR **c) addr = end - 1; } memsize2 = (memsize + 7) / 8; - memtmp = xmalloc (memsize + memsize2); + memtmp = xmalloc (uae_u8, memsize + memsize2); if (!memtmp) return; memset (memtmp + memsize, 0xff, memsize2); @@ -1320,7 +1320,7 @@ static void cheatsearch (TCHAR **c) console_out (L"Search reset\n"); xfree (vlist); listsize = memsize; - vlist = xcalloc (listsize >> 3, 1); + vlist = xcalloc (uae_u8, listsize >> 3); return; } val = readint (c); @@ -1342,7 +1342,7 @@ static void cheatsearch (TCHAR **c) if (vlist == NULL) { listsize = memsize; - vlist = xcalloc (listsize >> 3, 1); + vlist = xcalloc (uae_u8, listsize >> 3); } count = 0; @@ -1417,8 +1417,8 @@ static void illg_init (void) uae_u8 c = 3; uaecptr addr, end; - illgdebug = xcalloc (0x01000000, 1); - illghdebug = xcalloc (65536, 1); + illgdebug = xcalloc (uae_u8, 0x01000000); + illghdebug = xcalloc (uae_u8, 65536); if (!illgdebug || !illghdebug) { illg_free(); return; @@ -1552,7 +1552,7 @@ static void smc_detect_init (TCHAR **c) if (currprefs.z3fastmem_size) smc_size = currprefs.z3fastmem_start + currprefs.z3fastmem_size; smc_size += 4; - smc_table = xmalloc (smc_size * sizeof (struct smc_item)); + smc_table = xmalloc (struct smc_item, smc_size); if (!smc_table) return; for (i = 0; i < smc_size; i++) { @@ -1932,9 +1932,9 @@ static void initialize_memwatch (int mode) deinitialize_memwatch (); as = currprefs.address_space_24 ? 256 : 65536; - debug_mem_banks = xmalloc (sizeof (addrbank*) * as); - debug_mem_area = xmalloc (sizeof (addrbank) * as); - membank_stores = xcalloc (sizeof (struct membank_store), 32); + debug_mem_banks = xmalloc (addrbank*, as); + debug_mem_area = xmalloc (addrbank, as); + membank_stores = xcalloc (struct membank_store, 32); oa = NULL; for (i = 0; i < as; i++) { a1 = debug_mem_banks[i] = debug_mem_area + i; @@ -2016,7 +2016,7 @@ static void memwatch_dump (int num) TCHAR *buf; int multiplier = num < 0 ? MEMWATCH_TOTAL : 1; - buf = malloc (50 * multiplier * sizeof (TCHAR)); + buf = xmalloc (TCHAR, 50 * multiplier); if (!buf) return; memwatch_dump2 (buf, 50 * multiplier, num); @@ -2259,7 +2259,7 @@ STATIC_INLINE uaecptr BPTR2APTR (uaecptr addr) static TCHAR *BSTR2CSTR (uae_u8 *bstr) { WCHAR *s; - char *cstr = xmalloc (bstr[0] + 1); + char *cstr = xmalloc (char, bstr[0] + 1); if (cstr) { memcpy (cstr, bstr + 1, bstr[0]); cstr[bstr[0]] = 0; @@ -2275,7 +2275,7 @@ static void print_task_info (uaecptr node) int process = get_byte (node + 8) == 13 ? 1 : 0; console_out_f (L"%08X: ", node); - s = au (get_real_address (get_long (node + 10))); + s = au ((char*)get_real_address (get_long (node + 10))); console_out_f (process ? L" PROCESS '%s'" : L" TASK '%s'\n", s); xfree (s); if (process) { @@ -2339,7 +2339,7 @@ static void show_exec_lists (TCHAR t) return; node = get_long (list); while (get_long (node)) { - TCHAR *name = au (get_real_address (get_long (node + 10))); + TCHAR *name = au ((char*)get_real_address (get_long (node + 10))); console_out_f (L"%08x %s\n", node, name); xfree (name); node = get_long (node); @@ -3339,7 +3339,7 @@ void debug (void) uaecptr execbase = get_long (4); uaecptr activetask = get_long (execbase + 276); int process = get_byte (activetask + 8) == 13 ? 1 : 0; - uae_u8 *name = get_real_address (get_long (activetask + 10)); + char *name = (char*)get_real_address (get_long (activetask + 10)); if (process) { uaecptr cli = BPTR2APTR(get_long (activetask + 172)); uaecptr seglist = 0; @@ -3347,13 +3347,13 @@ void debug (void) uae_char *command = NULL; if (cli) { if (processname) - command = get_real_address (BPTR2APTR(get_long (cli + 16))); + command = (char*)get_real_address (BPTR2APTR(get_long (cli + 16))); seglist = BPTR2APTR(get_long (cli + 60)); } else { seglist = BPTR2APTR(get_long (activetask + 128)); seglist = BPTR2APTR(get_long (seglist + 12)); } - if (activetask == processptr || (processname && (!stricmp(name, processname) || (command && command[0] && !strnicmp(command + 1, processname, command[0]) && processname[command[0]] == 0)))) { + if (activetask == processptr || (processname && (!stricmp (name, processname) || (command && command[0] && !strnicmp (command + 1, processname, command[0]) && processname[command[0]] == 0)))) { while (seglist) { uae_u32 size = get_long (seglist - 4) - 4; if (pc >= (seglist + 4) && pc < (seglist + size)) { @@ -3479,6 +3479,7 @@ struct mmunode { struct mmunode *next; }; static struct mmunode **mmunl; +extern regstruct mmu_backup_regs; #define MMU_READ_U (1 << 0) #define MMU_WRITE_U (1 << 1) @@ -3777,7 +3778,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2) } mmu_slots = 1 << ((currprefs.address_space_24 ? 24 : 32) - MMU_PAGE_SHIFT); - mmunl = xcalloc (sizeof (struct mmunode*) * mmu_slots, 1); + mmunl = xcalloc (struct mmunode*, mmu_slots); size = 1; p2 = get_long (p); while (get_long (p2) != 0xffffffff) { @@ -3785,7 +3786,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2) size++; } p = banks = get_long (p); - snptr = mmubanks = xmalloc (sizeof (struct mmudata) * size); + snptr = mmubanks = xmalloc (struct mmudata, size); for (;;) { int off; if (getmmubank(snptr, p)) @@ -3793,12 +3794,12 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2) p += 16; off = snptr->addr >> MMU_PAGE_SHIFT; if (mmunl[off] == NULL) { - mn = mmunl[off] = xcalloc (sizeof (struct mmunode), 1); + mn = mmunl[off] = xcalloc (struct mmunode, 1); } else { mn = mmunl[off]; while (mn->next) mn = mn->next; - mn = mn->next = xcalloc (sizeof (struct mmunode), 1); + mn = mn->next = xcalloc (struct mmunode, 1); } mn->mmubank = snptr; snptr++; diff --git a/disk.c b/disk.cpp similarity index 98% rename from disk.c rename to disk.cpp index 76a7d7cc..3b4acde5 100644 --- a/disk.c +++ b/disk.cpp @@ -134,7 +134,7 @@ typedef struct { #define DRIVE_ID_35HD 0xAAAAAAAA #define DRIVE_ID_525SD 0x55555555 /* 40 track 5.25 drive , kickstart does not recognize this */ -typedef enum { ADF_NORMAL, ADF_EXT1, ADF_EXT2, ADF_FDI, ADF_IPF, ADF_CATWEASEL, ADF_PCDOS } drive_filetype; +typedef enum { ADF_NONE = -1, ADF_NORMAL, ADF_EXT1, ADF_EXT2, ADF_FDI, ADF_IPF, ADF_CATWEASEL, ADF_PCDOS } drive_filetype; typedef struct { struct zfile *diskfile; struct zfile *writediskfile; @@ -280,7 +280,7 @@ static void createbootblock (uae_u8 *sector, int bootable) memcpy (sector, bootblock, sizeof (bootblock)); } -static void createrootblock (uae_u8 *sector, uae_u8 *disk_name) +static void createrootblock (uae_u8 *sector, char *disk_name) { memset (sector, 0, FS_FLOPPY_BLOCKSIZE); sector[0+3] = 2; @@ -288,7 +288,7 @@ static void createrootblock (uae_u8 *sector, uae_u8 *disk_name) sector[312] = sector[313] = sector[314] = sector[315] = (uae_u8)0xff; sector[316+2] = 881 >> 8; sector[316+3] = 881 & 255; sector[432] = strlen (disk_name); - strcpy (sector + 433, disk_name); + strcpy ((char*)sector + 433, disk_name); sector[508 + 3] = 1; disk_date (sector + 420); memcpy (sector + 472, sector + 420, 3 * 4); @@ -325,7 +325,7 @@ static int createdirheaderblock (uae_u8 *sector, int parent, const char *filenam pl (sector, 4, block); disk_date (sector + 512 - 92); sector[512 - 80] = strlen (filename); - strcpy (sector + 512 - 79, filename); + strcpy ((char*)sector + 512 - 79, filename); pl (sector, 512 - 12, parent); pl (sector, 512 - 4, 2); return block; @@ -355,7 +355,7 @@ static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, co pl (sector, FS_FLOPPY_BLOCKSIZE - 188, size); disk_date (sector + FS_FLOPPY_BLOCKSIZE - 92); sector[FS_FLOPPY_BLOCKSIZE - 80] = strlen (filename); - strcpy (sector + FS_FLOPPY_BLOCKSIZE - 79, filename); + strcpy ((char*)sector + FS_FLOPPY_BLOCKSIZE - 79, filename); pl (sector, FS_FLOPPY_BLOCKSIZE - 12, parent); pl (sector, FS_FLOPPY_BLOCKSIZE - 4, -3); extensioncounter = 0; @@ -563,7 +563,7 @@ static void drive_image_free (drive *drv) #endif break; } - drv->filetype = -1; + drv->filetype = ADF_NONE; zfile_fclose (drv->diskfile); drv->diskfile = 0; zfile_fclose (drv->writediskfile); @@ -654,8 +654,10 @@ static void update_drive_gui (int num) static void drive_fill_bigbuf (drive * drv,int); -struct zfile *DISK_validate_filename (const TCHAR *fname, int leave_open, int *wrprot, uae_u32 *crc32) +int DISK_validate_filename (const TCHAR *fname, int leave_open, int *wrprot, uae_u32 *crc32, struct zfile **zf) { + if (zf) + *zf = NULL; if (crc32) *crc32 = 0; if (leave_open) { @@ -670,7 +672,11 @@ struct zfile *DISK_validate_filename (const TCHAR *fname, int leave_open, int *w } if (f && crc32) *crc32 = zfile_crc32 (f); - return f; + if (!zf) + zfile_fclose (f); + else + *zf = f; + return f ? 1 : 0; } else { if (zfile_exists (fname)) { if (wrprot) @@ -681,7 +687,7 @@ struct zfile *DISK_validate_filename (const TCHAR *fname, int leave_open, int *w *crc32 = zfile_crc32 (f); zfile_fclose (f); } - return (void*)1; + return 1; } else { if (wrprot) *wrprot = 1; @@ -719,7 +725,7 @@ static int read_header_ext2 (struct zfile *diskfile, trackid *trackdata, int *nu zfile_fseek (diskfile, 0, SEEK_SET); zfile_fread (buffer, 1, 8, diskfile); - if (strncmp (buffer, "UAE-1ADF", 8)) + if (strncmp ((char*)buffer, "UAE-1ADF", 8)) return 0; zfile_fread (buffer, 1, 4, diskfile); *num_tracks = buffer[2] * 256 + buffer[3]; @@ -728,7 +734,7 @@ static int read_header_ext2 (struct zfile *diskfile, trackid *trackdata, int *nu for (i = 0; i < (*num_tracks); i++) { tid = trackdata + i; zfile_fread (buffer, 2 + 2 + 4 + 4, 1, diskfile); - tid->type = buffer[3]; + tid->type = (image_tracktype)buffer[3]; tid->revolutions = buffer[2] + 1; tid->len = buffer[5] * 65536 + buffer[6] * 256 + buffer[7]; tid->bitlen = buffer[9] * 65536 + buffer[10] * 256 + buffer[11]; @@ -771,7 +777,9 @@ TCHAR *DISK_get_saveimagepath (const TCHAR *name) static struct zfile *getwritefile (const TCHAR *name, int *wrprot) { - return DISK_validate_filename (DISK_get_saveimagepath (name), 1, wrprot, NULL); + struct zfile *zf; + DISK_validate_filename (DISK_get_saveimagepath (name), 1, wrprot, NULL, &zf); + return zf; } static int iswritefileempty (const TCHAR *name) @@ -826,7 +834,7 @@ static int diskfile_iswriteprotect (const TCHAR *fname, int *needwritefile, driv *needwritefile = 0; *drvtype = DRV_35_DD; - zf1 = DISK_validate_filename (fname, 1, &wrprot1, NULL); + DISK_validate_filename (fname, 1, &wrprot1, NULL, &zf1); if (!zf1) return 1; if (zfile_iscompressed (zf1)) { @@ -867,11 +875,11 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR trackid *tid; int num_tracks, size; int canauto; - TCHAR *ext; + const TCHAR *ext; gui_disk_image_change (dnum, fname); drive_image_free (drv); - drv->diskfile = DISK_validate_filename (fname, 1, &drv->wrprot, &drv->crc32); + DISK_validate_filename (fname, 1, &drv->wrprot, &drv->crc32, &drv->diskfile); drv->ddhd = 1; drv->num_secs = 0; drv->hard_num_cyls = p->dfxtype[dnum] == DRV_525_SD ? 40 : 80; @@ -1666,7 +1674,7 @@ static void drive_fill_bigbuf (drive * drv, int force) } /* Update ADF_EXT2 track header */ -static void diskfile_update (struct zfile *diskfile, trackid *ti, int len, uae_u8 type) +static void diskfile_update (struct zfile *diskfile, trackid *ti, int len, image_tracktype type) { uae_u8 buf[2 + 2 + 4 + 4], *zerobuf; @@ -1681,7 +1689,7 @@ static void diskfile_update (struct zfile *diskfile, trackid *ti, int len, uae_u do_put_mem_long ((uae_u32 *) (buf + 8), ti->bitlen); zfile_fwrite (buf, sizeof (buf), 1, diskfile); if (ti->len > (len + 7) / 8) { - zerobuf = malloc (ti->len); + zerobuf = xmalloc (uae_u8, ti->len); memset (zerobuf, 0, ti->len); zfile_fseek (diskfile, ti->offs, SEEK_SET); zfile_fwrite (zerobuf, 1, ti->len, diskfile); @@ -2059,7 +2067,7 @@ void disk_creatediskfile (TCHAR *name, int type, drive_type adftype, TCHAR *disk } f = zfile_fopen (name, L"wb", 0); - chunk = xmalloc (32768); + chunk = xmalloc (uae_u8, 32768); if (f && chunk) { int cylsize = sectors * 2 * 512; memset (chunk, 0, 32768); @@ -2069,7 +2077,7 @@ void disk_creatediskfile (TCHAR *name, int type, drive_type adftype, TCHAR *disk if (adftype <= 1) { if (i == 0) { /* boot block */ - strcpy (chunk, "DOS"); + strcpy ((char*)chunk, "DOS"); } else if (i == file_size / 2) { int block = file_size / 1024; /* root block */ @@ -2079,7 +2087,7 @@ void disk_creatediskfile (TCHAR *name, int type, drive_type adftype, TCHAR *disk chunk[316+2] = (block + 1) >> 8; chunk[316+3] = (block + 1) & 255; s = ua (disk_name); chunk[432] = strlen (s); - strcpy (chunk + 433, s); + strcpy ((char*)chunk + 433, s); xfree (s); chunk[508 + 3] = 1; disk_date (chunk + 420); @@ -2172,7 +2180,7 @@ int disk_setwriteprotect (int num, const TCHAR *name, int protect) drive_type drvtype; oldprotect = diskfile_iswriteprotect (name, &needwritefile, &drvtype); - zf1 = DISK_validate_filename (name, 1, &wrprot1, NULL); + DISK_validate_filename (name, 1, &wrprot1, NULL, &zf1); if (!zf1) return 0; if (zfile_iscompressed (zf1)) @@ -3496,7 +3504,7 @@ static uae_u32 getadfcrc (drive *drv) return 0; zfile_fseek (drv->diskfile, 0, SEEK_END); size = zfile_ftell (drv->diskfile); - b = (uae_u8*)malloc (size); + b = xmalloc (uae_u8, size); if (!b) return 0; zfile_fseek (drv->diskfile, 0, SEEK_SET); @@ -3515,7 +3523,7 @@ uae_u8 *save_disk (int num, int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = xmalloc (2+1+1+1+1+4+4+256); + dstbak = dst = xmalloc (uae_u8, 2+1+1+1+1+4+4+256); save_u32 (drv->drive_id); /* drive type ID */ save_u8 ((drv->motoroff ? 0:1) | ((disabled & (1 << num)) ? 2 : 0) | (drv->idbit ? 4 : 0) | (drv->dskchange ? 8 : 0)); save_u8 (drv->cyl); /* cylinder */ @@ -3555,7 +3563,7 @@ uae_u8 *save_floppy(int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = xmalloc (2 + 1 + 1 + 1 + 1 + 2); + dstbak = dst = xmalloc (uae_u8, 2 + 1 + 1 + 1 + 1 + 2); save_u16 (word); /* current fifo (low word) */ save_u8 (bitoffset); /* dma bit offset */ save_u8 (dma_enable); /* disk sync found */ diff --git a/diskutil.c b/diskutil.cpp similarity index 100% rename from diskutil.c rename to diskutil.cpp diff --git a/dongle.c b/dongle.cpp similarity index 100% rename from dongle.c rename to dongle.cpp diff --git a/drawing.c b/drawing.cpp similarity index 99% rename from drawing.c rename to drawing.cpp index 31de0d04..0ca26e49 100644 --- a/drawing.c +++ b/drawing.cpp @@ -866,7 +866,7 @@ STATIC_INLINE uae_u8 render_sprites (int pos, int dualpf, uae_u8 apixel, int aga return 0; } -#include "linetoscr.c" +#include "linetoscr.cpp" #ifdef ECS_DENISE /* ECS SuperHires special cases */ @@ -1724,8 +1724,8 @@ static void init_aspect_maps (void) xfree (amiga2aspect_line_map); /* At least for this array the +1 is necessary. */ - amiga2aspect_line_map = xmalloc (sizeof (int) * (MAXVPOS + 1) * 2 + 1); - native2amiga_line_map = xmalloc (sizeof (int) * gfxvidinfo.height); + amiga2aspect_line_map = xmalloc (int, (MAXVPOS + 1) * 2 + 1); + native2amiga_line_map = xmalloc (int, gfxvidinfo.height); maxl = (MAXVPOS + 1) * (linedbld ? 2 : 1); min_ypos_for_screen = minfirstline << (linedbl ? 1 : 0); diff --git a/driveclick.c b/driveclick.cpp similarity index 98% rename from driveclick.c rename to driveclick.cpp index f4e058da..76bdae66 100644 --- a/driveclick.c +++ b/driveclick.cpp @@ -49,7 +49,7 @@ uae_s16 *decodewav (uae_u8 *s, int *lenp) if (!memcmp (s, "data", 4)) { s += 4; len = s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24); - dst = xmalloc (len); + dst = xmalloc (uae_s16, len / 2); memcpy (dst, s + 4, len); *lenp = len / 2; return dst; @@ -78,7 +78,7 @@ static int loadsample (TCHAR *path, struct drvsample *ds) } zfile_fseek (f, 0, SEEK_END); size = zfile_ftell (f); - buf = xmalloc (size); + buf = xmalloc (uae_u8, size); zfile_fseek (f, 0, SEEK_SET); zfile_fread (buf, size, 1, f); zfile_fclose (f); @@ -216,7 +216,7 @@ void driveclick_reset (void) clickbuffer = NULL; if (!wave_initialized) return; - clickbuffer = xmalloc (paula_sndbufsize); + clickbuffer = xmalloc (uae_s16, paula_sndbufsize / 2); sample_step = (freq << DS_SHIFT) / currprefs.sound_freq; } diff --git a/enforcer.c b/enforcer.cpp similarity index 99% rename from enforcer.c rename to enforcer.cpp index 835f9931..b0563cad 100644 --- a/enforcer.c +++ b/enforcer.cpp @@ -126,7 +126,7 @@ static int enforcer_decode_hunk_and_offset (TCHAR *buf, uae_u32 pc) uae_u8 *native_string = amiga2native (string, 100); if (native_string) { - if (!strcmp (native_string, "SegTracker")) + if (!strcmp ((char*)native_string, "SegTracker")) break; } node = amiga_node_next (node); @@ -162,7 +162,7 @@ static int enforcer_decode_hunk_and_offset (TCHAR *buf, uae_u32 pc) offset = pc - address - 4; name = get_long (node + 8); /* ln_Name */ if (name) { - native_name = au (amiga2native(name,100)); + native_name = au ((char*)amiga2native(name,100)); if (!native_name) native_name = my_strdup (L"Unknown"); } else { @@ -213,7 +213,7 @@ static void enforcer_display_hit (const TCHAR *addressmode, uae_u32 pc, uaecptr goto end; task_name = get_long (this_task + 10); /* ln_Name */ - native_task_name = au (amiga2native (task_name, 100)); + native_task_name = au ((char*)amiga2native (task_name, 100)); /*if (strcmp(native_task_name,"c:MCP")!=0) { Exception (0x2d,0); diff --git a/epsonprinter.c b/epsonprinter.cpp similarity index 99% rename from epsonprinter.c rename to epsonprinter.cpp index 2525e85e..2afd205f 100644 --- a/epsonprinter.c +++ b/epsonprinter.cpp @@ -797,7 +797,7 @@ static void resetPrinterHard(void) resetPrinter(); } -static printer_init(Bit16u dpi2, Bit16u width, Bit16u height, TCHAR* output2, int multipageOutput2, int numpins) +static int printer_init(Bit16u dpi2, Bit16u width, Bit16u height, TCHAR* output2, int multipageOutput2, int numpins) { pins = numpins; if (ft == NULL || FT_Init_FreeType(&FTlib)) @@ -818,7 +818,7 @@ static printer_init(Bit16u dpi2, Bit16u width, Bit16u height, TCHAR* output2, in page_h = (Bitu)(defaultPageHeight*dpi); pagesize = page_w * page_h; page_pitch = page_w; - page = xcalloc (pagesize, 1); + page = xcalloc (uae_u8, pagesize); curFont = NULL; charRead = false; autoFeed = false; @@ -856,10 +856,11 @@ static printer_init(Bit16u dpi2, Bit16u width, Bit16u height, TCHAR* output2, in #endif } } + return 1; }; -static printer_close(void) +static void printer_close(void) { if (page != NULL) { @@ -1473,7 +1474,7 @@ static int processCommandChar(Bit8u ch) break; case 0x6b: // Select typeface (ESC k) if (params[0] <= 11 || params[0] == 30 || params[0] == 31) - LQtypeFace = params[0]; + LQtypeFace = (Typeface)params[0]; updateFont(); break; case 0x6c: // Set left margin (ESC 1) diff --git a/ersatz.c b/ersatz.cpp similarity index 100% rename from ersatz.c rename to ersatz.cpp diff --git a/expansion.c b/expansion.cpp similarity index 99% rename from expansion.c rename to expansion.cpp index 198f9142..40754282 100644 --- a/expansion.c +++ b/expansion.cpp @@ -947,7 +947,7 @@ static void expamem_init_filesys (void) * Zorro III expansion memory */ -static void expamem_map_z3fastmem_2 (addrbank *bank, int *startp, uae_u32 size, uae_u32 allocated) +static void expamem_map_z3fastmem_2 (addrbank *bank, uaecptr *startp, uae_u32 size, uae_u32 allocated) { int z3fs = ((expamem_hi | (expamem_lo >> 4)) << 16); int start = *startp; diff --git a/fdi2raw.c b/fdi2raw.cpp similarity index 99% rename from fdi2raw.c rename to fdi2raw.cpp index c567a71c..177ae853 100644 --- a/fdi2raw.c +++ b/fdi2raw.cpp @@ -105,7 +105,7 @@ static void *fdi_malloc (int size) return (int*)p + 1; } #else -#define fdi_free free +#define fdi_free xfree #define fdi_malloc xmalloc #endif @@ -195,10 +195,10 @@ static uae_u8 *expand_tree (uae_u8 *stream, NODE *node) temp = *stream++; temp2 = 0x80; } - node->left = (NODE*)fdi_malloc (sizeof (NODE)); + node->left = fdi_malloc (NODE, 1); memset (node->left, 0, sizeof (NODE)); stream_temp = expand_tree (stream, node->left); - node->right = (NODE*)fdi_malloc (sizeof (NODE)); + node->right = fdi_malloc (NODE ,1); memset (node->right, 0, sizeof (NODE)); return expand_tree (stream_temp, node->right); } @@ -1358,7 +1358,7 @@ static uae_u8 *fdi_decompress (int pulses, uae_u8 *sizep, uae_u8 *src, int *dofr src += 4; } } else if (mode == 1) { - dst = (uae_u8*)fdi_malloc (pulses *4); + dst = fdi_malloc (uae_u8, pulses *4); *dofree = 1; fdi_decode (src, pulses, dst); } else { @@ -1864,7 +1864,7 @@ static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache) idx_off3 = 4; } } else { - idxp = (uae_u8*)fdi_malloc (pulses * 2); + idxp = fdi_malloc (uae_u8, pulses * 2); idx_free = 1; for (i = 0; i < pulses; i++) { idxp[i * 2 + 0] = 2; @@ -2015,7 +2015,7 @@ FDI *fdi2raw_header(struct zfile *f) FDI *fdi; debuglog ("ALLOC: memory allocated %d\n", fdi_allocated); - fdi = (FDI*)fdi_malloc(sizeof(FDI)); + fdi = fdi_malloc (FDI, 1); memset (fdi, 0, sizeof (FDI)); fdi->file = f; oldseek = zfile_ftell (fdi->file); @@ -2041,10 +2041,10 @@ FDI *fdi2raw_header(struct zfile *f) } } - fdi->mfmsync_buffer = (int*)fdi_malloc (MAX_MFM_SYNC_BUFFER * sizeof(int)); - fdi->track_src_buffer = (uae_u8*)fdi_malloc (MAX_SRC_BUFFER); - fdi->track_dst_buffer = (uae_u8*)fdi_malloc (MAX_DST_BUFFER); - fdi->track_dst_buffer_timing = (uae_u16*)fdi_malloc (MAX_TIMING_BUFFER); + fdi->mfmsync_buffer = fdi_malloc (int, MAX_MFM_SYNC_BUFFER); + fdi->track_src_buffer = fdi_malloc (uae_u8, MAX_SRC_BUFFER); + fdi->track_dst_buffer = fdi_malloc (uae_u8, MAX_DST_BUFFER); + fdi->track_dst_buffer_timing = fdi_malloc (uae_u16, MAX_TIMING_BUFFER / 2); fdi->last_track = ((fdi->header[142] << 8) + fdi->header[143]) + 1; fdi->last_track *= fdi->header[144] + 1; diff --git a/filesys.c b/filesys.cpp similarity index 96% rename from filesys.c rename to filesys.cpp index 6792db0c..7bef42e7 100644 --- a/filesys.c +++ b/filesys.cpp @@ -136,7 +136,7 @@ typedef struct { uae_thread_id tid; struct _unit *self; /* Reset handling */ - volatile uae_sem_t reset_sync_sem; + uae_sem_t reset_sync_sem; volatile int reset_state; /* RDB stuff */ @@ -365,7 +365,7 @@ TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const continue; if (!_tcscmp (p + i, L":\\")) { xfree (p); - p = xmalloc (10 * sizeof (TCHAR)); + p = xmalloc (TCHAR, 10); p[0] = rootdir[0]; p[1] = 0; i = 0; @@ -777,7 +777,7 @@ typedef struct key { struct key *next; a_inode *aino; uae_u32 uniq; - void *fd; + struct fs_filehandle *fd; uae_u64 file_pos; int dosmode; int createmode; @@ -793,7 +793,7 @@ typedef struct notify { typedef struct exallkey { uae_u32 id; - void *dirhandle; + struct fs_dirhandle *dirhandle; TCHAR *fn; uaecptr control; } ExAllKey; @@ -963,60 +963,72 @@ static Unit* return u; } - -static void *fs_opendir (Unit *u, const TCHAR *nname) +static struct fs_dirhandle *fs_opendir (Unit *u, const TCHAR *nname) { - if (u->volflags & MYVOLUMEINFO_ARCHIVE) - return zfile_opendir_archive (nname); + struct fs_dirhandle *fsd = xmalloc (struct fs_dirhandle, 1); + fsd->isarch = !!(u->volflags & MYVOLUMEINFO_ARCHIVE); + if (fsd->isarch) + fsd->zd = zfile_opendir_archive (nname); else - return my_opendir (nname); + fsd->od = my_opendir (nname); + return fsd; } -static void fs_closedir (Unit *u, void *d) +static void fs_closedir (struct fs_dirhandle *fsd) { - if (u->volflags & MYVOLUMEINFO_ARCHIVE) - zfile_closedir_archive (d); + if (!fsd) + return; + if (fsd->isarch) + zfile_closedir_archive (fsd->zd); else - my_closedir (d); + my_closedir (fsd->od); + xfree (fsd); } -static void *fs_open (Unit *unit, const TCHAR *name, int flags) +static struct fs_filehandle *fs_open (Unit *unit, const TCHAR *name, int flags) { - int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; - if (isarch) - return zfile_open_archive (name, flags); + struct fs_filehandle *fsf = xmalloc (struct fs_filehandle, 1); + fsf->isarch = !!(unit->volflags & MYVOLUMEINFO_ARCHIVE); + if (fsf->isarch) + fsf->zf = zfile_open_archive (name, flags); else - return my_open (name, flags); + fsf->of = my_open (name, flags); + return fsf; } -static void fs_close (Unit *unit, void *fd) +static void fs_close (struct fs_filehandle *fd) { - int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; - if (isarch) - zfile_close_archive (fd); + if (!fd) + return; + if (fd->isarch) + zfile_close_archive (fd->zf); else - my_close (fd); + my_close (fd->of); } -static unsigned int fs_read (Unit *unit, void *d, void *b, unsigned int size) +static unsigned int fs_read (struct fs_filehandle *fsf, void *b, unsigned int size) { - int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; - if (isarch) - return zfile_read_archive (d, b, size); + if (fsf->isarch) + return zfile_read_archive (fsf->zf, b, size); else - return my_read (d, b, size); + return my_read (fsf->of, b, size); } -static uae_u64 fs_lseek64 (Unit *unit, void *d, uae_s64 offset, int whence) +static unsigned int fs_write (struct fs_filehandle *fsf, void *b, unsigned int size) { - int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; - if (isarch) - return zfile_lseek_archive (d, offset, whence); + if (fsf->isarch) + return 0; + return my_write (fsf->of, b, size); +} + +static uae_u64 fs_lseek64 (struct fs_filehandle *fsf, uae_s64 offset, int whence) +{ + if (fsf->isarch) + return zfile_lseek_archive (fsf->zf, offset, whence); else - return my_lseek (d, offset, whence); + return my_lseek (fsf->of, offset, whence); } -static uae_u32 fs_lseek (Unit *unit, void *d, uae_s32 offset, int whence) +static uae_u32 fs_lseek (struct fs_filehandle *fsf, uae_s32 offset, int whence) { - int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; - if (isarch) - return (uae_u32)zfile_lseek_archive (d, (uae_s32)offset, whence); + if (fsf->isarch) + return (uae_u32)zfile_lseek_archive (fsf->zf, (uae_s32)offset, whence); else - return (uae_u32)my_lseek (d, (uae_s32)offset, whence); + return (uae_u32)my_lseek (fsf->of, (uae_s32)offset, whence); } static void set_volume_name (Unit *unit) { @@ -1051,7 +1063,7 @@ static void clear_exkeys (Unit *unit) unit->examine_keys[i].uniq = 0; } for (i = 0; i < EXALLKEYS; i++) { - fs_closedir (unit, unit->exalls[i].dirhandle); + fs_closedir (unit->exalls[i].dirhandle); unit->exalls[i].dirhandle = NULL; xfree (unit->exalls[i].fn); unit->exalls[i].fn = NULL; @@ -1479,7 +1491,7 @@ static void update_child_names (Unit *unit, a_inode *a, a_inode *parent) write_log (L"malformed file name"); } name_start++; - new_name = xmalloc ((_tcslen (name_start) + l0) * sizeof (TCHAR)); + new_name = xmalloc (TCHAR, _tcslen (name_start) + l0); _tcscpy (new_name, parent->nname); _tcscat (new_name, dirsep); _tcscat (new_name, name_start); @@ -1594,7 +1606,7 @@ static a_inode *lookup_aino (Unit *unit, uae_u32 uniq) TCHAR *build_nname (const TCHAR *d, const TCHAR *n) { TCHAR dsep[2] = { FSDB_DIR_SEPARATOR, 0 }; - TCHAR *p = xmalloc ((_tcslen (d) + 1 + _tcslen (n) + 1) * sizeof (TCHAR)); + TCHAR *p = xmalloc (TCHAR, _tcslen (d) + 1 + _tcslen (n) + 1); _tcscpy (p, d); _tcscat (p, dsep); _tcscat (p, n); @@ -1603,7 +1615,7 @@ TCHAR *build_nname (const TCHAR *d, const TCHAR *n) TCHAR *build_aname (const TCHAR *d, const TCHAR *n) { - TCHAR *p = xmalloc ((_tcslen (d) + 1 + _tcslen (n) + 1) * sizeof (TCHAR)); + TCHAR *p = xmalloc (TCHAR, _tcslen (d) + 1 + _tcslen (n) + 1); _tcscpy (p, d); _tcscat (p, L"/"); _tcscat (p, n); @@ -1775,7 +1787,7 @@ static a_inode *new_child_aino (Unit *unit, a_inode *base, TCHAR *rel) if (nn == 0) return 0; - aino = xcalloc (sizeof (a_inode), 1); + aino = xcalloc (a_inode, 1); if (aino == 0) return 0; aino->aname = modified_rel ? modified_rel : my_strdup (rel); @@ -1800,7 +1812,7 @@ static a_inode *new_child_aino (Unit *unit, a_inode *base, TCHAR *rel) static a_inode *create_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int isdir) { - a_inode *aino = xcalloc (sizeof (a_inode), 1); + a_inode *aino = xcalloc (a_inode, 1); if (aino == 0) return 0; @@ -1824,7 +1836,7 @@ static a_inode *create_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int is return aino; } -static a_inode *lookup_child_aino (Unit *unit, a_inode *base, TCHAR *rel, uae_u32 *err) +static a_inode *lookup_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int *err) { a_inode *c = base->child; int l0 = _tcslen (rel); @@ -1876,7 +1888,7 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, TCHAR * if (!isarch) c = fsdb_lookup_aino_nname (base, rel); if (c == 0) { - c = xcalloc (sizeof (a_inode), 1); + c = xcalloc (a_inode, 1); if (c == 0) { *err = ERROR_NO_FREE_STORE; return 0; @@ -1902,7 +1914,7 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, TCHAR * return c; } -static a_inode *get_aino (Unit *unit, a_inode *base, const TCHAR *rel, uae_u32 *err) +static a_inode *get_aino (Unit *unit, a_inode *base, const TCHAR *rel, int *err) { TCHAR *tmp; TCHAR *p; @@ -1968,7 +1980,7 @@ static uae_u32 notifyhash (TCHAR *s) static Notify *new_notify (Unit *unit, TCHAR *name) { - Notify *n = xmalloc (sizeof (Notify)); + Notify *n = xmalloc (Notify, 1); uae_u32 hash = notifyhash (name); n->next = unit->notifyhash[hash]; unit->notifyhash[hash] = n; @@ -2018,7 +2030,7 @@ static Unit *startup_create_unit (UnitInfo *uinfo, int num) int i; Unit *unit, *u; - unit = xcalloc (sizeof (Unit), 1); + unit = xcalloc (Unit, 1); /* keep list in insertion order */ u = units; if (u) { @@ -2089,8 +2101,8 @@ static void filesys_start_thread (UnitInfo *ui, int nr) } #ifdef UAE_FILESYS_THREADS if (is_hardfile (nr) == FILESYS_VIRTUAL) { - ui->unit_pipe = xmalloc (sizeof (smp_comm_pipe)); - ui->back_pipe = xmalloc (sizeof (smp_comm_pipe)); + ui->unit_pipe = xmalloc (smp_comm_pipe, 1); + ui->back_pipe = xmalloc (smp_comm_pipe, 1); init_comm_pipe (ui->unit_pipe, 100, 3); init_comm_pipe (ui->back_pipe, 100, 1); uae_start_thread (L"filesys", filesys_thread, (void *)ui, &ui->tid); @@ -2259,7 +2271,7 @@ static void free_key (Unit *unit, Key *k) } if (k->fd != NULL) - fs_close (unit, k->fd); + fs_close (k->fd); xfree(k); } @@ -2281,7 +2293,7 @@ static Key *lookup_key (Unit *unit, uae_u32 uniq) static Key *new_key (Unit *unit) { - Key *k = xcalloc (sizeof (Key), 1); + Key *k = xcalloc (Key, 1); k->uniq = ++key_uniq; k->fd = NULL; k->file_pos = 0; @@ -2313,7 +2325,7 @@ static void TRACE((L" }\n")); } -static a_inode *find_aino (Unit *unit, uaecptr lock, const TCHAR *name, uae_u32 *err) +static a_inode *find_aino (Unit *unit, uaecptr lock, const TCHAR *name, int *err) { a_inode *a; @@ -2391,7 +2403,7 @@ static void notify_check (Unit *unit, a_inode *a) for (n = unit->notifyhash[hash]; n; n = n->next) { uaecptr nr = n->notifyrequest; if (same_aname(n->partname, a->aname)) { - uae_u32 err; + int err; a_inode *a2 = find_aino (unit, 0, n->fullname, &err); if (err == 0 && a == a2) notify_send (unit, n); @@ -2402,7 +2414,7 @@ static void notify_check (Unit *unit, a_inode *a) for (n = unit->notifyhash[hash]; n; n = n->next) { uaecptr nr = n->notifyrequest; if (same_aname(n->partname, a->parent->aname)) { - uae_u32 err; + int err; a_inode *a2 = find_aino (unit, 0, n->fullname, &err); if (err == 0 && a->parent == a2) notify_send (unit, n); @@ -2457,7 +2469,7 @@ static void n->notifyrequest = nr; n->fullname = name; if (flags & NRF_NOTIFY_INITIAL) { - uae_u32 err; + int err; a_inode *a = find_aino (unit, 0, n->fullname, &err); if (err == 0) notify_send (unit, n); @@ -2522,7 +2534,7 @@ static void uaecptr name = GET_PCK_ARG2 (packet) << 2; long mode = GET_PCK_ARG3 (packet); a_inode *a; - uae_u32 err; + int err; if (mode != SHARED_LOCK && mode != EXCLUSIVE_LOCK) { TRACE((L"Bad mode %d (should be %d or %d).\n", mode, SHARED_LOCK, EXCLUSIVE_LOCK)); @@ -2883,7 +2895,8 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec int size, size2; int entrytype; TCHAR *xs = NULL, *commentx = NULL; - uae_u32 flags = 15, days, mins, ticks; + uae_u32 flags = 15; + long days, mins, ticks; struct _stat64 statbuf; int fsdb_can = fsdb_cando (unit); uae_u16 uid = 0, gid = 0; @@ -2998,8 +3011,7 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp a_inode *aino, *base; int ok; uae_u32 err; - int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; - void *d; + struct fs_dirhandle *d; TCHAR fn[MAX_DPATH]; if (lock != 0) @@ -3010,11 +3022,11 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp d = eak->dirhandle; if (!eak->fn) { do { - if (isarch) - ok = zfile_readdir_archive (d, fn); + if (d->isarch) + ok = zfile_readdir_archive (d->zd, fn); else - ok = my_readdir (d, fn); - } while (ok && !isarch && fsdb_name_invalid (fn)); + ok = my_readdir (d->od, fn); + } while (ok && !d->isarch && fsdb_name_invalid (fn)); if (!ok) return 0; } else { @@ -3054,7 +3066,7 @@ static int action_examine_all_end (Unit *unit, dpacket packet) doserr = ERROR_OBJECT_WRONG_TYPE; } else { eak->id = 0; - fs_closedir (unit, eak->dirhandle); + fs_closedir (eak->dirhandle); xfree (eak->fn); eak->fn = NULL; eak->dirhandle = NULL; @@ -3077,9 +3089,8 @@ static int action_examine_all (Unit *unit, dpacket packet) uaecptr control = GET_PCK_ARG5 (packet); ExAllKey *eak = NULL; - int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; a_inode *base; - void *d; + struct fs_dirhandle *d; int ok, i; uaecptr exp; uae_u32 id, doserr = ERROR_NO_MORE_ENTRIES; @@ -3175,7 +3186,7 @@ fail: PUT_PCK_RES2 (packet, doserr); if (eak) { eak->id = 0; - fs_closedir (unit, eak->dirhandle); + fs_closedir (eak->dirhandle); eak->dirhandle = NULL; xfree (eak->fn); eak->fn = NULL; @@ -3239,9 +3250,8 @@ finished - they may never finish! */ static void populate_directory (Unit *unit, a_inode *base) { - void *d; + struct fs_dirhandle *d; a_inode *aino; - int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; d = fs_opendir (unit, base->nname); if (!d) @@ -3260,18 +3270,18 @@ static void populate_directory (Unit *unit, a_inode *base) /* Find next file that belongs to the Amiga fs (skipping things like "..", "." etc. */ do { - if (isarch) - ok = zfile_readdir_archive(d, fn); + if (d->isarch) + ok = zfile_readdir_archive(d->zd, fn); else - ok = my_readdir (d, fn); - } while (ok && !isarch && fsdb_name_invalid (fn)); + ok = my_readdir (d->od, fn); + } while (ok && !d->isarch && fsdb_name_invalid (fn)); if (!ok) break; /* This calls init_child_aino, which will notice that the parent is being ExNext()ed, and it will increment the locked counts. */ aino = lookup_child_aino_for_exnext (unit, base, fn, &err); } - fs_closedir (unit, d); + fs_closedir (d); } static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info) @@ -3360,8 +3370,8 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb uaecptr name = GET_PCK_ARG3 (packet) << 2; a_inode *aino; Key *k; - void *fd; - uae_u32 err; + struct fs_filehandle *fd; + int err; mode_t openmode; int aino_created = 0; int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; @@ -3486,7 +3496,7 @@ static void uaecptr lock = GET_PCK_ARG2 (packet) << 2; a_inode *aino; Key *k; - void *fd; + struct fs_filehandle *fd; mode_t openmode; int mode; int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE; @@ -3638,7 +3648,7 @@ static void if (valid_address (addr, size)) { uae_u8 *realpt; realpt = get_real_address (addr); - actual = fs_read (unit, k->fd, realpt, size); + actual = fs_read (k->fd, realpt, size); if (actual == 0) { PUT_PCK_RES1 (packet, 0); @@ -3657,19 +3667,19 @@ static void write_log (L"unixfs warning: Bad pointer passed for read: %08x, size %d\n", addr, size); /* ugh this is inefficient but easy */ - old = fs_lseek (unit, k->fd, 0, SEEK_CUR); - filesize = fs_lseek (unit, k->fd, 0, SEEK_END); - fs_lseek (unit, k->fd, old, SEEK_SET); + old = fs_lseek (k->fd, 0, SEEK_CUR); + filesize = fs_lseek (k->fd, 0, SEEK_END); + fs_lseek (k->fd, old, SEEK_SET); if (size > filesize) size = filesize; - buf = xmalloc (size); + buf = xmalloc (uae_u8, size); if (!buf) { PUT_PCK_RES1 (packet, -1); PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE); return; } - actual = fs_read (unit, k->fd, buf, size); + actual = fs_read (k->fd, buf, size); if (actual < 0) { PUT_PCK_RES1 (packet, 0); @@ -3693,7 +3703,7 @@ static void uaecptr addr = GET_PCK_ARG2 (packet); long size = GET_PCK_ARG3 (packet); long actual; - TCHAR *buf; + uae_u8 *buf; int i; if (k == 0) { @@ -3713,13 +3723,13 @@ static void if (valid_address (addr, size)) { uae_u8 *realpt = get_real_address (addr); - actual = my_write (k->fd, realpt, size); + actual = fs_write (k->fd, realpt, size); } else { write_log (L"unixfs warning: Bad pointer passed for write: %08x, size %d\n", addr, size); /* ugh this is inefficient but easy */ - buf = (TCHAR *)malloc(size); + buf = xmalloc (uae_u8, size); if (!buf) { PUT_PCK_RES1 (packet, -1); PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE); @@ -3729,7 +3739,7 @@ static void for (i = 0; i < size; i++) buf[i] = get_byte (addr + i); - actual = my_write (k->fd, buf, size); + actual = fs_write (k->fd, buf, size); xfree (buf); } @@ -3767,11 +3777,11 @@ static void TRACE((L"ACTION_SEEK(%s,%d,%d)\n", k->aino->nname, pos, mode)); gui_flicker_led (LED_HD, unit->unit, 1); - old = fs_lseek (unit, k->fd, 0, SEEK_CUR); + old = fs_lseek (k->fd, 0, SEEK_CUR); { uae_s64 temppos; - uae_s64 filesize = fs_lseek64 (unit, k->fd, 0, SEEK_END); - fs_lseek (unit, k->fd, old, SEEK_SET); + uae_s64 filesize = fs_lseek64 (k->fd, 0, SEEK_END); + fs_lseek (k->fd, old, SEEK_SET); if (whence == SEEK_CUR) temppos = old + pos; @@ -3786,12 +3796,12 @@ static void return; } } - res = fs_lseek64 (unit, k->fd, pos, whence); + res = fs_lseek64 (k->fd, pos, whence); if (-1 == res || old > MAXFILESIZE32) { PUT_PCK_RES1 (packet, -1); PUT_PCK_RES2 (packet, ERROR_SEEK_ERROR); - fs_lseek64 (unit, k->fd, old, SEEK_SET); + fs_lseek64 (k->fd, old, SEEK_SET); res = old; } else { PUT_PCK_RES1 (packet, old); @@ -3806,7 +3816,7 @@ static void uaecptr name = GET_PCK_ARG3 (packet) << 2; uae_u32 mask = GET_PCK_ARG4 (packet); a_inode *a; - uae_u32 err; + int err; TRACE((L"ACTION_SET_PROTECT(0x%lx,\"%s\",0x%lx)\n", lock, bstr (unit, name), mask)); @@ -3844,7 +3854,7 @@ static void action_set_comment (Unit * unit, dpacket packet) uaecptr comment = GET_PCK_ARG4 (packet) << 2; TCHAR *commented = NULL; a_inode *a; - uae_u32 err; + int err; if (unit->ui.readonly) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -3861,7 +3871,7 @@ static void action_set_comment (Unit * unit, dpacket packet) } if (_tcslen (commented) > 0) { TCHAR *p = commented; - commented = xmalloc (81 * sizeof (TCHAR)); + commented = xmalloc (TCHAR, 81); _tcsncpy (commented, p, 80); commented[80] = 0; } else { @@ -3925,7 +3935,7 @@ static void long mode = GET_PCK_ARG3 (packet); unsigned long uniq; a_inode *a = NULL, *olda = NULL; - uae_u32 err = 0; + int err = 0; TRACE((L"ACTION_CHANGE_MODE(0x%lx,%d,%d)\n", object, type, mode)); if (! object || (type != CHANGE_FH && type != CHANGE_LOCK)) { @@ -4032,7 +4042,7 @@ static void uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr name = GET_PCK_ARG2 (packet) << 2; a_inode *aino; - uae_u32 err; + int err; TRACE((L"ACTION_CREATE_DIR(0x%lx,\"%s\")\n", lock, bstr (unit, name))); @@ -4137,11 +4147,11 @@ static void } /* Write one then truncate: that should give the right size in all cases. */ - offset = fs_lseek (unit, k->fd, offset, whence); - my_write (k->fd, /* whatever */(uae_u8*)&k1, 1); + offset = fs_lseek (k->fd, offset, whence); + fs_write (k->fd, /* whatever */(uae_u8*)&k1, 1); if (k->file_pos > offset) k->file_pos = offset; - fs_lseek (unit, k->fd, (off_t)k->file_pos, SEEK_SET); + fs_lseek (k->fd, (off_t)k->file_pos, SEEK_SET); /* Brian: no bug here; the file _must_ be one byte too large after writing The write is supposed to guarantee that the file can't be smaller than @@ -4166,7 +4176,7 @@ static int relock_do(Unit *unit, a_inode *a1) knext = k1->next; if (k1->aino == a1 && k1->fd) { wehavekeys++; - fs_close (unit, k1->fd); + fs_close (k1->fd); write_log (L"handle %p freed\n", k1->fd); } } @@ -4200,7 +4210,7 @@ static void relock_re (Unit *unit, a_inode *a1, a_inode *a2, int failed) write_log (L"relocking failed '%s' -> '%s'\n", a1->nname, a2->nname); free_key (unit, k1); } else { - fs_lseek64 (unit, k1->fd, k1->file_pos, SEEK_SET); + fs_lseek64 (k1->fd, k1->file_pos, SEEK_SET); } } } @@ -4212,7 +4222,7 @@ static void uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr name = GET_PCK_ARG2 (packet) << 2; a_inode *a; - uae_u32 err; + int err; TRACE((L"ACTION_DELETE_OBJECT(0x%lx,\"%s\")\n", lock, bstr (unit, name))); @@ -4274,7 +4284,7 @@ static void uaecptr date = GET_PCK_ARG4 (packet); a_inode *a; struct utimbuf ut; - uae_u32 err; + int err; TRACE((L"ACTION_SET_DATE(0x%lx,\"%s\")\n", lock, bstr (unit, name))); @@ -4307,7 +4317,7 @@ static void uaecptr lock2 = GET_PCK_ARG3 (packet) << 2; uaecptr name2 = GET_PCK_ARG4 (packet) << 2; a_inode *a1, *a2; - uae_u32 err1, err2; + int err1, err2; Key *k1, *knext; int wehavekeys = 0; @@ -4514,11 +4524,11 @@ static void action_change_file_position64 (Unit *unit, dpacket packet) TRACE((L"ACTION_CHANGE_FILE_POSITION64(%s,%I64d,%d)\n", k->aino->nname, pos, mode)); gui_flicker_led (LED_HD, unit->unit, 1); - old = fs_lseek64 (unit, k->fd, 0, SEEK_CUR); + old = fs_lseek64 (k->fd, 0, SEEK_CUR); { uae_s64 temppos; - uae_s64 filesize = fs_lseek64 (unit, k->fd, 0, SEEK_END); - fs_lseek64 (unit, k->fd, old, SEEK_SET); + uae_s64 filesize = fs_lseek64 (k->fd, 0, SEEK_END); + fs_lseek64 (k->fd, old, SEEK_SET); if (whence == SEEK_CUR) temppos = old + pos; @@ -4533,7 +4543,7 @@ static void action_change_file_position64 (Unit *unit, dpacket packet) return; } } - res = fs_lseek64 (unit, k->fd, pos, whence); + res = fs_lseek64 (k->fd, pos, whence); if (-1 == res) { PUT_PCK64_RES1 (packet, DOS_FALSE); @@ -4597,11 +4607,11 @@ static void action_change_file_size64 (Unit *unit, dpacket packet) } /* Write one then truncate: that should give the right size in all cases. */ - offset = fs_lseek (unit, k->fd, offset, whence); - my_write (k->fd, /* whatever */(uae_u8*)&k1, 1); + offset = fs_lseek (k->fd, offset, whence); + fs_write (k->fd, /* whatever */(uae_u8*)&k1, 1); if (k->file_pos > offset) k->file_pos = offset; - fs_lseek (unit, k->fd, k->file_pos, SEEK_SET); + fs_lseek (k->fd, k->file_pos, SEEK_SET); if (my_truncate (k->aino->nname, offset) == -1) { PUT_PCK64_RES1 (packet, DOS_FALSE); @@ -4627,11 +4637,11 @@ static void action_get_file_size64 (Unit *unit, dpacket packet) return; } TRACE((L"ACTION_GET_FILE_SIZE64(%s)\n", k->aino->nname)); - old = fs_lseek64 (unit, k->fd, 0, SEEK_CUR); + old = fs_lseek64 (k->fd, 0, SEEK_CUR); if (old >= 0) { - filesize = fs_lseek64 (unit, k->fd, 0, SEEK_END); + filesize = fs_lseek64 (k->fd, 0, SEEK_END); if (filesize >= 0) { - fs_lseek64 (unit, k->fd, old, SEEK_SET); + fs_lseek64 (k->fd, old, SEEK_SET); PUT_PCK64_RES1 (packet, filesize); PUT_PCK64_RES2 (packet, 0); return; @@ -5008,7 +5018,7 @@ void filesys_free_handles (void) for (k1 = u->keys; k1; k1 = knext) { knext = k1->next; if (k1->fd) - fs_close (u, k1->fd); + fs_close (k1->fd); xfree (k1); } u->keys = NULL; @@ -5323,9 +5333,9 @@ static TCHAR *device_dupfix (uaecptr expbase, TCHAR *devname) return my_strdup (newname); } -static void dump_partinfo (uae_char *name, int num, uaecptr pp, int partblock) +static void dump_partinfo (uae_u8 *name, int num, uaecptr pp, int partblock) { - TCHAR *s = au (name); + TCHAR *s = au ((char*)name); uae_u32 dostype = get_long (pp + 80); uae_u64 size; @@ -5421,7 +5431,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke rdblock, fileblock, hfd->cylinders, hfd->sectors, hfd->heads); } - buf = xmalloc (readblocksize); + buf = xmalloc (uae_u8, readblocksize); for (i = 0; i <= partnum; i++) { if (i == 0) partblock = rl (bufrdb + 28); @@ -5451,7 +5461,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke m68k_dreg (regs, 7) = m68k_dreg (regs, 7) & ~1; buf[37 + buf[36]] = 0; /* zero terminate BSTR */ - s = au (buf + 37); + s = au ((char*)buf + 37); uip->rdb_devname_amiga[partnum] = ds (device_dupfix (get_long (parmpacket + PP_EXPLIB), s)); xfree (s); put_long (parmpacket, uip->rdb_devname_amiga[partnum]); /* name */ @@ -5533,7 +5543,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke put_byte (parmpacket + PP_FSHDSTART + i, buf[32 + i]); put_long (parmpacket + PP_FSHDSTART, dostype); /* we found required FSHD block */ - fsmem = xmalloc (262144); + fsmem = xmalloc (uae_u8, 262144); lsegblock = rl (buf + 72); i = 0; for (;;) { @@ -5636,7 +5646,7 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket) size = zfile_ftell (zf); if (size > 0) { zfile_fseek (zf, 0, SEEK_SET); - uip->rdb_filesysstore = xmalloc (size); + uip->rdb_filesysstore = xmalloc (uae_u8, size); zfile_fread (uip->rdb_filesysstore, size, 1, zf); } zfile_fclose (zf); @@ -5825,7 +5835,7 @@ void filesys_install_code (void) bootrom_header = 3 * 4; align(4); a = here (); -#include "filesys_bootrom.c" +#include "filesys_bootrom.cpp" bootrom_items = dlg (a + 8); /* The last offset comes from the code itself, look for it near the top. */ @@ -5834,7 +5844,7 @@ void filesys_install_code (void) filesys_initcode = a + dlg (b) + bootrom_header - 4; } -#include "od-win32/win32_filesys.c" +#include "od-win32/win32_filesys.cpp" static uae_u8 *restore_filesys_hardfile (UnitInfo *ui, uae_u8 *src) { @@ -5904,7 +5914,7 @@ static a_inode *restore_filesys_get_base (Unit *u, TCHAR *npath) /* iterate from root to last to previous path part, * create ainos if not already created. */ - path = xcalloc((_tcslen (npath) + 2) * sizeof (TCHAR), 1); + path = xcalloc(TCHAR, _tcslen (npath) + 2); cnt = 1; for (;;) { _tcscpy (path, npath); @@ -5971,7 +5981,7 @@ static TCHAR *makenativepath (UnitInfo *ui, TCHAR *apath) int i; TCHAR *pn; /* create native path. FIXME: handle 'illegal' characters */ - pn = xcalloc ((_tcslen (apath) + 1 + _tcslen (ui->rootdir) + 1) * sizeof (TCHAR), 1); + pn = xcalloc (TCHAR, _tcslen (apath) + 1 + _tcslen (ui->rootdir) + 1); _stprintf (pn, L"%s/%s", ui->rootdir, apath); if (FSDB_DIR_SEPARATOR != '/') { for (i = 0; i < _tcslen (pn); i++) { @@ -5990,7 +6000,7 @@ static uae_u8 *restore_aino (UnitInfo *ui, Unit *u, uae_u8 *src) a_inode *base, *a; missing = 0; - a = xcalloc (sizeof (a_inode), 1); + a = xcalloc (a_inode, 1); a->uniq = restore_u64 (); a->locked_children = restore_u32 (); a->exnext_count = restore_u32 (); @@ -6061,13 +6071,13 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src) int savedsize, uniq; TCHAR *p, *pn; mode_t openmode; - DWORD err; + int err; int missing; a_inode *a; Key *k; missing = 0; - k = xcalloc (sizeof (Key), 1); + k = xcalloc (Key, 1); k->uniq = restore_u64 (); k->file_pos = restore_u32 (); k->createmode = restore_u32 (); @@ -6095,11 +6105,11 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src) write_log (L"*** FS: Open file '%s' is missing, creating dummy file!\n", p); k->fd = fs_open (u, pn, openmode | O_CREAT |O_BINARY); if (k->fd) { - uae_u8 *buf = xcalloc (10000, 1); + uae_u8 *buf = xcalloc (uae_u8, 10000); int sp = savedsize; while (sp) { int s = sp >= 10000 ? 10000 : sp; - my_write(k->fd, buf, s); + fs_write (k->fd, buf, s); sp -= s; } xfree(buf); @@ -6115,14 +6125,14 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src) missing = 1; } else { uae_s64 s; - s = fs_lseek64 (u, k->fd, 0, SEEK_END); + s = fs_lseek64 (k->fd, 0, SEEK_END); if (s != savedsize) write_log (L"FS: restored file '%s' size changed! orig=%d, now=%d!!\n", p, savedsize, s); if (k->file_pos > s) { write_log (L"FS: restored filepos larger than size of file '%s'!! %d > %d\n", p, k->file_pos, s); k->file_pos = s; } - fs_lseek64 (u,k->fd, k->file_pos, SEEK_SET); + fs_lseek64 (k->fd, k->file_pos, SEEK_SET); } } xfree (p); @@ -6137,13 +6147,13 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src) static uae_u8 *restore_notify (UnitInfo *ui, Unit *u, uae_u8 *src) { - Notify *n = xcalloc (sizeof (Notify), 1); + Notify *n = xcalloc (Notify, 1); uae_u32 hash; TCHAR *s; n->notifyrequest = restore_u32 (); s = restore_string (); - n->fullname = xmalloc ((_tcslen (ui->volname) + 2 + _tcslen (s) + 1) * sizeof (TCHAR)); + n->fullname = xmalloc (TCHAR, _tcslen (ui->volname) + 2 + _tcslen (s) + 1); _stprintf (n->fullname, L"%s:%s", ui->volname, s); xfree(s); s = _tcsrchr (n->fullname, '/'); @@ -6212,7 +6222,7 @@ static TCHAR *getfullaname(a_inode *a) TCHAR *p; int first = 1; - p = xcalloc (2000 * sizeof (TCHAR), 1); + p = xcalloc (TCHAR, 2000); while (a) { int len = _tcslen (a->aname); memmove (p + len + 1, p, (_tcslen (p) + 1) * sizeof (TCHAR)); @@ -6275,10 +6285,10 @@ static uae_u8 *save_key (uae_u8 *dst, Key *k) save_u32 ((uae_u32)k->file_pos); save_u32 (k->createmode); save_u32 (k->dosmode); - size = my_lseek (k->fd, 0, SEEK_END); + size = fs_lseek (k->fd, 0, SEEK_END); save_u32 ((uae_u32)size); save_u64 (k->aino->uniq); - my_lseek (k->fd, k->file_pos, SEEK_SET); + fs_lseek (k->fd, k->file_pos, SEEK_SET); save_string (fn); save_u64 (k->file_pos); save_u64 (size); @@ -6376,7 +6386,7 @@ uae_u8 *save_filesys_common (int *len) uae_u8 *dstbak, *dst; if (nr_units () == 0) return NULL; - dstbak = dst = xmalloc (1000); + dstbak = dst = xmalloc (uae_u8, 1000); save_u32 (2); save_u64 (a_uniq); save_u64 (key_uniq); @@ -6408,7 +6418,7 @@ uae_u8 *save_filesys (int num, int *len) if (type == FILESYS_VIRTUAL && (ui->self == NULL || ui->volname == NULL)) return NULL; write_log (L"FS_FILESYS: '%s' '%s'\n", ui->devname, ui->volname); - dstbak = dst = xmalloc (100000); + dstbak = dst = xmalloc (uae_u8, 100000); save_u32 (2); /* version */ save_u32 (ui->devno); save_u16 (type); diff --git a/filesys_bootrom.c b/filesys_bootrom.cpp similarity index 100% rename from filesys_bootrom.c rename to filesys_bootrom.cpp diff --git a/fpp.c b/fpp.cpp similarity index 99% rename from fpp.c rename to fpp.cpp index c5940cdd..d819c92e 100644 --- a/fpp.c +++ b/fpp.cpp @@ -325,6 +325,8 @@ STATIC_INLINE tointtype toint (fptype src, fptype minval, fptype maxval) #endif } +extern int isinf (double x); + uae_u32 get_fpsr (void) { uae_u32 answer = regs.fpsr & 0x00ffffff; @@ -1744,7 +1746,7 @@ uae_u8 *save_fpu (int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = malloc (4+4+8*10+4+4+4+4+4); + dstbak = dst = xmalloc (uae_u8, 4+4+8*10+4+4+4+4+4); save_u32 (currprefs.fpu_model); save_u32 (0x80000000); for (i = 0; i < 8; i++) { diff --git a/fsdb.c b/fsdb.cpp similarity index 94% rename from fsdb.c rename to fsdb.cpp index b8af475a..c24b9939 100644 --- a/fsdb.c +++ b/fsdb.cpp @@ -146,18 +146,18 @@ void fsdb_clean_dir (a_inode *dir) static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, long off) { uae_u32 mode; - a_inode *aino = (a_inode *) xcalloc (sizeof (a_inode), 1); + a_inode *aino = xcalloc (a_inode, 1); TCHAR *s; mode = do_get_mem_long ((uae_u32 *)(buf + 1)); buf += 5; - aino->aname = au (buf); + aino->aname = au ((char*)buf); buf += 257; - s = au (buf); + s = au ((char*)buf); aino->nname = build_nname (base->nname, s); xfree (s); buf += 257; - aino->comment = *buf != '\0' ? au (buf) : 0; + aino->comment = *buf != '\0' ? au ((char*)buf) : 0; fsdb_fill_file_attrs (base, aino); aino->amigaos_mode = mode; aino->has_dbentry = 1; @@ -181,7 +181,7 @@ a_inode *fsdb_lookup_aino_aname (a_inode *base, const TCHAR *aname) TCHAR *s; if (fread (buf, 1, sizeof buf, f) < sizeof buf) break; - s = au (buf + 5); + s = au ((char*)buf + 5); if (buf[0] != 0 && same_aname (s, aname)) { long pos = ftell (f) - sizeof buf; fclose (f); @@ -210,7 +210,7 @@ a_inode *fsdb_lookup_aino_nname (a_inode *base, const TCHAR *nname) uae_u8 buf[1 + 4 + 257 + 257 + 81]; if (fread (buf, 1, sizeof buf, f) < sizeof buf) break; - if (buf[0] != 0 && strcmp (buf + 5 + 257, s) == 0) { + if (buf[0] != 0 && strcmp ((char*)buf + 5 + 257, s) == 0) { long pos = ftell (f) - sizeof buf; fclose (f); xfree (s); @@ -239,7 +239,7 @@ int fsdb_used_as_nname (a_inode *base, const TCHAR *nname) break; if (buf[0] == 0) continue; - s = au (buf + 5 + 257); + s = au ((char*)buf + 5 + 257); if (_tcscmp (s, nname) == 0) { xfree (s); fclose (f); @@ -271,11 +271,11 @@ static void write_aino (FILE *f, a_inode *aino) buf[0] = aino->needs_dbentry; do_put_mem_long ((uae_u32 *)(buf + 1), aino->amigaos_mode); - ua_copy (buf + 5, 256, aino->aname); + ua_copy ((char*)buf + 5, 256, aino->aname); buf[5 + 256] = '\0'; - ua_copy (buf + 5 + 257, 256, nname_begin (aino->nname)); + ua_copy ((char*)buf + 5 + 257, 256, nname_begin (aino->nname)); buf[5 + 257 + 256] = '\0'; - ua_copy (buf + 5 + 2 * 257, 80, aino->comment ? aino->comment : L""); + ua_copy ((char*)buf + 5 + 2 * 257, 80, aino->comment ? aino->comment : L""); buf[5 + 2 * 257 + 80] = '\0'; aino->db_offset = ftell (f); fwrite (buf, 1, sizeof buf, f); @@ -359,7 +359,7 @@ void fsdb_dir_writeback (a_inode *dir) i = 0; while (!aino->has_dbentry && i < size) { - TCHAR *s = au (tmpbuf + i + 5); + TCHAR *s = au ((char*)tmpbuf + i + 5); if (!_tcscmp (s, aino->aname)) { aino->has_dbentry = 1; aino->db_offset = i; diff --git a/fsdb_unix.c b/fsdb_unix.cpp similarity index 100% rename from fsdb_unix.c rename to fsdb_unix.cpp diff --git a/fsusage.c b/fsusage.cpp similarity index 100% rename from fsusage.c rename to fsusage.cpp index 2e418f4d..ac8f8fe4 100644 --- a/fsusage.c +++ b/fsusage.cpp @@ -16,6 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "sysconfig.h" +#include "sysdeps.h" #include #include @@ -46,7 +47,6 @@ static long adjust_blocks (long blocks, int fromsize, int tosize) } #ifdef _WIN32 -#include "sysdeps.h" #include "od-win32/posixemu.h" #include int get_fs_usage (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp) diff --git a/gayle.c b/gayle.cpp similarity index 98% rename from gayle.c rename to gayle.cpp index 35fb41f1..febb4454 100644 --- a/gayle.c +++ b/gayle.cpp @@ -1486,17 +1486,17 @@ static void initsramattr (int size, int readonly) *p++= 4; /* PCMCIA 2.1 */ *p++= 1; if (real) { - ua_copy (p, -1, hfd->product_id); - p += strlen (p) + 1; - ua_copy(p, -1, hfd->product_rev); + ua_copy ((char*)p, -1, hfd->product_id); + p += strlen ((char*)p) + 1; + ua_copy ((char*)p, -1, hfd->product_rev); } else { - strcpy (p, "UAE"); - p += strlen (p) + 1; - strcpy (p, "68000"); + strcpy ((char*)p, "UAE"); + p += strlen ((char*)p) + 1; + strcpy ((char*)p, "68000"); } - p += strlen (p) + 1; - sprintf (p, "Generic Emulated %dKB PCMCIA SRAM Card", size >> 10); - p += strlen (p) + 1; + p += strlen ((char*)p) + 1; + sprintf ((char*)p, "Generic Emulated %dKB PCMCIA SRAM Card", size >> 10); + p += strlen ((char*)p) + 1; *p++= 0; *p++= 0xff; *rp = p - rp; @@ -1583,7 +1583,7 @@ static int initpcmcia (const TCHAR *path, int readonly, int reset) return 0; freepcmcia (reset); if (!pcmcia_sram) - pcmcia_sram = xcalloc (sizeof (struct hd_hardfiledata), 1); + pcmcia_sram = xcalloc (struct hd_hardfiledata, 1); if (!pcmcia_sram->hfd.handle_valid) reset = 1; if (reset) { @@ -1597,14 +1597,14 @@ static int initpcmcia (const TCHAR *path, int readonly, int reset) pcmcia_common_size = 0; pcmcia_readonly = readonly; pcmcia_attrs_size = 256; - pcmcia_attrs = xcalloc (pcmcia_attrs_size, 1); + pcmcia_attrs = xcalloc (uae_u8, pcmcia_attrs_size); if (!pcmcia_sram->hfd.drive_empty) { pcmcia_common_size = pcmcia_sram->hfd.virtsize; if (pcmcia_sram->hfd.virtsize > 4 * 1024 * 1024) { write_log (L"PCMCIA SRAM: too large device, %d bytes\n", pcmcia_sram->hfd.virtsize); pcmcia_common_size = 4 * 1024 * 1024; } - pcmcia_common = xcalloc (pcmcia_common_size, 1); + pcmcia_common = xcalloc (uae_u8, pcmcia_common_size); write_log (L"PCMCIA SRAM: '%s' open, size=%d\n", path, pcmcia_common_size); hdf_read (&pcmcia_sram->hfd, pcmcia_common, 0, pcmcia_common_size); pcmcia_card = 1; @@ -1838,7 +1838,7 @@ static void alloc_ide_mem (struct ide_hdf **ide, int max) for (i = 0; i < max; i++) { if (!ide[i]) - ide[i] = xcalloc (sizeof (struct ide_hdf), 1); + ide[i] = xcalloc (struct ide_hdf, 1); } } @@ -1960,7 +1960,7 @@ uae_u8 *save_gayle (int *len) if (currprefs.cs_ide <= 0) return NULL; - dstbak = dst = malloc (1000); + dstbak = dst = xmalloc (uae_u8, 1000); save_u8 (currprefs.cs_ide); save_u8 (gayle_int); save_u8 (gayle_irq); @@ -1983,7 +1983,7 @@ uae_u8 *save_ide (int num, int *len) ide = idedrive[num]; if (ide->hdhfd.size == 0) return NULL; - dstbak = dst = malloc (1000); + dstbak = dst = xmalloc (uae_u8, 1000); save_u32 (num); save_u64 (ide->hdhfd.size); save_string (ide->hdhfd.path); diff --git a/genblitter.c b/genblitter.cpp similarity index 100% rename from genblitter.c rename to genblitter.cpp diff --git a/gencpu.c b/gencpu.cpp similarity index 99% rename from gencpu.c rename to gencpu.cpp index 9a3af880..9e327636 100644 --- a/gencpu.c +++ b/gencpu.cpp @@ -353,6 +353,8 @@ static void irc2ir (void) if (!using_prefetch) return; printf ("\tregs.ir = regs.irc;\n"); + if (using_ce) + printf ("\tipl_fetch ();\n"); } static int did_prefetch; @@ -3756,10 +3758,10 @@ int main (int argc, char **argv) read_table68k (); do_merges (); - opcode_map = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs); - opcode_last_postfix = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs); - opcode_next_clev = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs); - counts = (unsigned long *) xmalloc (65536 * sizeof (unsigned long)); + opcode_map = xmalloc (int, nr_cpuop_funcs); + opcode_last_postfix = xmalloc (int, nr_cpuop_funcs); + opcode_next_clev = xmalloc (int, nr_cpuop_funcs); + counts = xmalloc (unsigned long, 65536); read_counts (); /* It would be a lot nicer to put all in one file (we'd also get rid of @@ -3768,7 +3770,7 @@ int main (int argc, char **argv) headerfile = fopen ("cputbl.h", "wb"); - stblfile = fopen ("cpustbl.c", "wb"); + stblfile = fopen ("cpustbl.cpp", "wb"); generate_includes (stblfile); using_prefetch = 0; @@ -3786,7 +3788,7 @@ int main (int argc, char **argv) if (generate_stbl) fprintf (stblfile, "#ifdef CPUEMU_%d\n", postfix); postfix2 = postfix; - sprintf (fname, "cpuemu_%d.c", postfix); + sprintf (fname, "cpuemu_%d.cpp", postfix); freopen (fname, "wb", stdout); generate_includes (stdout); } diff --git a/gencpu_mini.c b/gencpu_mini.cpp similarity index 100% rename from gencpu_mini.c rename to gencpu_mini.cpp diff --git a/gengenblitter.c b/gengenblitter.cpp similarity index 100% rename from gengenblitter.c rename to gengenblitter.cpp diff --git a/genlinetoscr.c b/genlinetoscr.cpp similarity index 98% rename from genlinetoscr.c rename to genlinetoscr.cpp index a12ccfdd..7c54dd82 100644 --- a/genlinetoscr.c +++ b/genlinetoscr.cpp @@ -13,12 +13,11 @@ /* Output for big-endian target if true, little-endian is false. */ int do_bigendian; -typedef enum -{ - DEPTH_8BPP, - DEPTH_16BPP, - DEPTH_32BPP, -} DEPTH_T; +typedef int DEPTH_T; + +#define DEPTH_8BPP 0 +#define DEPTH_16BPP 1 +#define DEPTH_32BPP 2 #define DEPTH_MAX DEPTH_32BPP static const char *get_depth_str (DEPTH_T bpp) @@ -41,17 +40,15 @@ static const char *get_depth_type_str (DEPTH_T bpp) return "uae_u32"; } +typedef int HMODE_T; -typedef enum -{ - HMODE_NORMAL, - HMODE_DOUBLE, - HMODE_DOUBLE2X, - HMODE_HALVE1, - HMODE_HALVE1F, - HMODE_HALVE2, - HMODE_HALVE2F -} HMODE_T; +#define HMODE_NORMAL 0 +#define HMODE_DOUBLE 1 +#define HMODE_DOUBLE2X 2 +#define HMODE_HALVE1 3 +#define HMODE_HALVE1F 4 +#define HMODE_HALVE2 5 +#define HMODE_HALVE2F 6 #define HMODE_MAX HMODE_HALVE2F static const char *get_hmode_str (HMODE_T hmode) diff --git a/genp2c.c b/genp2c.cpp similarity index 100% rename from genp2c.c rename to genp2c.cpp diff --git a/gfxlib.c b/gfxlib.cpp similarity index 100% rename from gfxlib.c rename to gfxlib.cpp diff --git a/gfxutil.c b/gfxutil.cpp similarity index 100% rename from gfxutil.c rename to gfxutil.cpp diff --git a/gtkui.c b/gtkui.cpp similarity index 100% rename from gtkui.c rename to gtkui.cpp diff --git a/hardfile.c b/hardfile.cpp similarity index 97% rename from hardfile.c rename to hardfile.cpp index 37092e31..146d16eb 100644 --- a/hardfile.c +++ b/hardfile.cpp @@ -215,7 +215,7 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b int cyls = 262144 / (cyl * 512); int size = cyl * cyls * 512; - rdb = (uae_u8*)xcalloc (size, 1); + rdb = xcalloc (uae_u8, size); hfd->virtual_rdb = rdb; hfd->virtual_size = size; part = rdb + 512; @@ -259,9 +259,9 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b pl(rdb, 37, 0); // autopark pl(rdb, 38, 2); // highrdskblock pl(rdb, 39, -1); // res - ua_copy (rdb + 40 * 4, -1, hfd->vendor_id); - ua_copy (rdb + 42 * 4, -1, hfd->product_id); - ua_copy (rdb + 46 * 4, -1, L"UAE"); + ua_copy ((char*)rdb + 40 * 4, -1, hfd->vendor_id); + ua_copy ((char*)rdb + 42 * 4, -1, hfd->product_id); + ua_copy ((char*)rdb + 46 * 4, -1, L"UAE"); rdb_crc (rdb); pl(part, 0, 0x50415254); @@ -274,7 +274,7 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b pl(part, 7, -1); pl(part, 8, 0); // devflags part[9 * 4] = _tcslen (hfd->device_name); - ua_copy (part + 9 * 4 + 1, -1, hfd->device_name); + ua_copy ((char*)part + 9 * 4 + 1, -1, hfd->device_name); denv = part + 128; pl(denv, 0, 80); @@ -405,10 +405,10 @@ static int hdf_open2 (struct hardfiledata *hfd, const TCHAR *pname) hfd->vhd_bamoffset = gl (tmp + 8 + 8 + 4); hfd->vhd_bamsize = (((hfd->virtsize + hfd->vhd_blocksize - 1) / hfd->vhd_blocksize) * 4 + 511) & ~511; size = hfd->vhd_bamoffset + hfd->vhd_bamsize; - hfd->vhd_header = xmalloc (size); + hfd->vhd_header = xmalloc (uae_u8, size); if (hdf_read_target (hfd, hfd->vhd_header, 0, size) != size) goto end; - hfd->vhd_sectormap = xmalloc (512); + hfd->vhd_sectormap = xmalloc (uae_u8, 512); hfd->vhd_sectormapblock = -1; hfd->vhd_bitmapsize = ((hfd->vhd_blocksize / (8 * 512)) + 511) & ~511; } @@ -460,11 +460,12 @@ int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd) extern int get_guid_target (uae_u8 *out); -static uae_u64 vhd_read (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len) +static uae_u64 vhd_read (struct hardfiledata *hfd, void *v, uae_u64 offset, uae_u64 len) { uae_u32 bamoffset; uae_u32 sectoroffset; uae_u64 read; + uae_u8 *dataptr = (uae_u8*)v; //write_log (L"%08x %08x\n", (uae_u32)offset, (uae_u32)len); read = 0; @@ -524,7 +525,7 @@ static int vhd_write_enlarge (struct hardfiledata *hfd, uae_u32 bamoffset) int v; len = hfd->vhd_blocksize + hfd->vhd_bitmapsize + 512; - buf = xcalloc (len, 1); + buf = xcalloc (uae_u8, len); if (!hdf_resize_target (hfd, hfd->physsize + len - 512)) { write_log (L"vhd_enlarge: failure\n"); return 0; @@ -553,11 +554,12 @@ static int vhd_write_enlarge (struct hardfiledata *hfd, uae_u32 bamoffset) return 1; } -static uae_u64 vhd_write (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len) +static uae_u64 vhd_write (struct hardfiledata *hfd, void *v, uae_u64 offset, uae_u64 len) { uae_u32 bamoffset; uae_u32 sectoroffset; uae_u64 written; + uae_u8 *dataptr = (uae_u8*)v; //write_log (L"%08x %08x\n", (uae_u32)offset, (uae_u32)len); written = 0; @@ -636,14 +638,14 @@ int vhd_create (const TCHAR *name, uae_u64 size, uae_u32 dostype) zf = zfile_fopen (name, L"wb", 0); if (!zf) goto end; - b = xcalloc (512 + 1024 + batsize + 512, 1); + b = xcalloc (uae_u8, 512 + 1024 + batsize + 512); if (zfile_fwrite (b, 512 + 1024 + batsize + 512, 1, zf) != 1) goto end; memset (&hfd, 0, sizeof hfd); hfd.virtsize = hfd.physsize = size; hfd.blocksize = 512; - strcpy (b, "conectix"); // cookie + strcpy ((char*)b, "conectix"); // cookie b[0x0b] = 2; // features b[0x0d] = 1; // version b[0x10 + 6] = 2; // data offset @@ -653,9 +655,9 @@ int vhd_create (const TCHAR *name, uae_u64 size, uae_u32 dostype) b[0x19] = tm >> 16; b[0x1a] = tm >> 8; b[0x1b] = tm >> 0; - strcpy (b + 0x1c, "vpc "); // creator application + strcpy ((char*)b + 0x1c, "vpc "); // creator application b[0x21] = 5; // creator version - strcpy (b + 0x24, "Wi2k"); // creator host os + strcpy ((char*)b + 0x24, "Wi2k"); // creator host os // original and current size b[0x28] = b[0x30] = size >> 56; b[0x29] = b[0x31] = size >> 48; @@ -692,7 +694,7 @@ int vhd_create (const TCHAR *name, uae_u64 size, uae_u32 dostype) // dynamic disk header memset (b, 0, 1024); // cookie - strcpy (b, "cxsparse"); + strcpy ((char*)b, "cxsparse"); // data offset for (i = 0; i < 8; i++) b[0x08 + i] = 0xff; @@ -757,9 +759,10 @@ static int hdf_read2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, in return hdf_read_target (hfd, buffer, offset, len); } -static void adide_decode (uae_u8 *buffer, int len) +static void adide_decode (void *v, int len) { int i; + uae_u8 *buffer = (uae_u8*)v; for (i = 0; i < len; i += 2) { uae_u8 *b = buffer + i; uae_u16 w = (b[0] << 8) | (b[1] << 0); @@ -809,9 +812,10 @@ static void adide_decode (uae_u8 *buffer, int len) b[1] = o >> 0; } } -static void adide_encode (uae_u8 *buffer, int len) +static void adide_encode (void *v, int len) { int i; + uae_u8 *buffer = (uae_u8*)v; for (i = 0; i < len; i += 2) { uae_u8 *b = buffer + i; uae_u16 w = (b[0] << 8) | (b[1] << 0); @@ -862,9 +866,11 @@ static void adide_encode (uae_u8 *buffer, int len) } } -static void hdf_byteswap (uae_u8 *b, int len) +static void hdf_byteswap (void *v, int len) { int i; + uae_u8 *b = (uae_u8*)v; + for (i = 0; i < len; i += 2) { uae_u8 tmp = b[i]; b[i] = b[i + 1]; @@ -1285,7 +1291,7 @@ static int handle_scsi (uaecptr request, struct hardfiledata *hfd) { uae_u32 acmd = get_long (request + 40); uaecptr scsi_data = get_long (acmd + 0); - uae_u32 scsi_len = get_long (acmd + 4); + int scsi_len = get_long (acmd + 4); uaecptr scsi_cmd = get_long (acmd + 12); uae_u16 scsi_cmd_len = get_word (acmd + 16); uae_u8 scsi_flags = get_byte (acmd + 20); diff --git a/hrtmon.rom.c b/hrtmon.rom.cpp similarity index 100% rename from hrtmon.rom.c rename to hrtmon.rom.cpp diff --git a/identify.c b/identify.cpp similarity index 100% rename from identify.c rename to identify.cpp diff --git a/include/blkdev.h b/include/blkdev.h index c5eda1c4..79cda4f3 100644 --- a/include/blkdev.h +++ b/include/blkdev.h @@ -52,9 +52,9 @@ struct device_scsi_info { struct amigascsi { uae_u8 *data; - uae_u32 len; + uae_s32 len; uae_u8 cmd[16]; - uae_u32 cmd_len; + uae_s32 cmd_len; uae_u8 flags; uae_u8 sensedata[256]; uae_u16 sense_len; diff --git a/include/bsdsocket.h b/include/bsdsocket.h index 6a223fe5..1393b480 100644 --- a/include/bsdsocket.h +++ b/include/bsdsocket.h @@ -86,8 +86,7 @@ struct socketbase { uae_u32 timeout; uae_u32 sigmp; #endif -} *socketbases; - +}; #define LIBRARY_SIZEOF 36 diff --git a/include/cpu_prefetch.h b/include/cpu_prefetch.h index cd402ee1..9c7f8b56 100644 --- a/include/cpu_prefetch.h +++ b/include/cpu_prefetch.h @@ -269,6 +269,11 @@ STATIC_INLINE uae_u32 next_ilong_020ce (void) #ifdef CPUEMU_12 +STATIC_INLINE void ipl_fetch (void) +{ + regs.ipl = regs.ipl_pin; +} + STATIC_INLINE uae_u32 mem_access_delay_word_read (uaecptr addr) { switch (ce_banktype[addr >> 16]) diff --git a/include/debug.h b/include/debug.h index d4f7fdde..19860cc7 100644 --- a/include/debug.h +++ b/include/debug.h @@ -67,9 +67,9 @@ extern void memwatch_dump2 (TCHAR *buf, int bufsize, int num); void debug_lgetpeek (uaecptr addr, uae_u32 v); void debug_wgetpeek (uaecptr addr, uae_u32 v); void debug_bgetpeek (uaecptr addr, uae_u32 v); -void debug_bputpeek(uaecptr addr, uae_u32 v); -void debug_wputpeek(uaecptr addr, uae_u32 v); -void debug_lputpeek(uaecptr addr, uae_u32 v); +void debug_bputpeek (uaecptr addr, uae_u32 v); +void debug_wputpeek (uaecptr addr, uae_u32 v); +void debug_lputpeek (uaecptr addr, uae_u32 v); enum debugtest_item { DEBUGTEST_BLITTER, DEBUGTEST_KEYBOARD, DEBUGTEST_FLOPPY, DEBUGTEST_MAX }; void debugtest (enum debugtest_item, const TCHAR *, ...); diff --git a/include/disk.h b/include/disk.h index cb5b3d97..c561594f 100644 --- a/include/disk.h +++ b/include/disk.h @@ -20,7 +20,7 @@ extern int disk_empty (int num); extern void disk_insert (int num, const TCHAR *name); extern void disk_insert_force (int num, const TCHAR *name); extern void DISK_check_change (void); -extern struct zfile *DISK_validate_filename (const TCHAR *, int, int *, uae_u32 *); +extern int DISK_validate_filename (const TCHAR *fname, int leave_open, int *wrprot, uae_u32 *crc32, struct zfile **zf); extern void DISK_handler (uae_u32); extern void DISK_update (int hpos); extern void DISK_hsync (int hpos); diff --git a/include/driveclick.h b/include/driveclick.h index 54f348c7..6be25f24 100644 --- a/include/driveclick.h +++ b/include/driveclick.h @@ -10,11 +10,11 @@ #define CLICK_TRACKS 84 struct drvsample { - unsigned int len; - unsigned pos; + int len; + int pos; uae_s16 *p; - unsigned int indexes[CLICK_TRACKS]; - unsigned int lengths[CLICK_TRACKS]; + int indexes[CLICK_TRACKS]; + int lengths[CLICK_TRACKS]; }; #define DS_CLICK 0 diff --git a/include/filesys.h b/include/filesys.h index 901852fa..610ab965 100644 --- a/include/filesys.h +++ b/include/filesys.h @@ -6,6 +6,8 @@ * Copyright 1997 Bernd Schmidt */ +struct hardfilehandle; + struct hardfiledata { uae_u64 virtsize; // virtual size uae_u64 physsize; // physical size (dynamic disk) @@ -15,7 +17,7 @@ struct hardfiledata { int surfaces; int reservedblocks; int blocksize; - void *handle; + struct hardfilehandle *handle; int handle_valid; int readonly; int dangerous; @@ -28,9 +30,9 @@ struct hardfiledata { TCHAR product_rev[4 + 1]; TCHAR device_name[256]; /* geometry from possible RDSK block */ - unsigned int cylinders; - unsigned int sectors; - unsigned int heads; + int cylinders; + int sectors; + int heads; uae_u8 *virtual_rdb; uae_u64 virtual_size; int unitnum; @@ -57,12 +59,12 @@ struct hd_hardfiledata { struct hardfiledata hfd; int bootpri; uae_u64 size; - unsigned int cyls; - unsigned int heads; - unsigned int secspertrack; - unsigned int cyls_def; - unsigned int secspertrack_def; - unsigned int heads_def; + int cyls; + int heads; + int secspertrack; + int cyls_def; + int secspertrack_def; + int heads_def; TCHAR *path; int ansi_version; }; diff --git a/include/fsdb.h b/include/fsdb.h index f81994be..197733b3 100644 --- a/include/fsdb.h +++ b/include/fsdb.h @@ -123,9 +123,12 @@ extern int fsdb_mode_representable_p (const a_inode *, int); extern int fsdb_mode_supported (const a_inode *); extern TCHAR *fsdb_create_unique_nname (a_inode *base, const TCHAR *); -extern void *my_opendir (const TCHAR*); -extern void my_closedir (void*); -extern int my_readdir (void*, TCHAR*); +struct my_opendir_s; +struct my_openfile_s; + +extern struct my_opendir_s *my_opendir (const TCHAR*); +extern void my_closedir (struct my_opendir_s*); +extern int my_readdir (struct my_opendir_s*, TCHAR*); extern int my_rmdir (const TCHAR*); extern int my_mkdir (const TCHAR*); @@ -133,11 +136,11 @@ extern int my_unlink (const TCHAR*); extern int my_rename (const TCHAR*, const TCHAR*); extern int my_setcurrentdir (const TCHAR *curdir, TCHAR *oldcur); -extern void *my_open (const TCHAR*, int); -extern void my_close (void*); -extern uae_s64 my_lseek (void*, uae_s64, int); -extern unsigned int my_read (void*, void*, unsigned int); -extern unsigned int my_write (void*, void*, unsigned int); +extern struct my_openfile_s *my_open (const TCHAR*, int); +extern void my_close (struct my_openfile_s*); +extern uae_s64 my_lseek (struct my_openfile_s*, uae_s64, int); +extern unsigned int my_read (struct my_openfile_s*, void*, unsigned int); +extern unsigned int my_write (struct my_openfile_s*, void*, unsigned int); extern int my_truncate (const TCHAR *name, uae_u64 len); extern int dos_errno (void); extern int my_existsfile (const TCHAR *name); diff --git a/include/fsusage.h b/include/fsusage.h index 24e3a3c3..01783bf2 100644 --- a/include/fsusage.h +++ b/include/fsusage.h @@ -25,13 +25,4 @@ struct fs_usage unsigned long fsu_ffree; /* Free file nodes. */ }; -#ifndef __P -#if defined (__GNUC__) || (defined (__STDC__) && __STDC__) -#define __P(args) args -#else -#define __P(args) () -#endif /* GCC. */ -#endif /* Not __P. */ - -int get_fs_usage __P ((const char *path, const char *disk, - struct fs_usage *fsp)); +int get_fs_usage (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp); diff --git a/include/gfxfilter.h b/include/gfxfilter.h index 605186d8..f8d2978d 100644 --- a/include/gfxfilter.h +++ b/include/gfxfilter.h @@ -22,26 +22,30 @@ typedef unsigned long uint32; typedef int bool; #endif -extern void S2X_configure (int rb, int gb, int bb, int rs, int gs, int bs); -extern int Init_2xSaI (int rb, int gb, int bb, int rs, int gs, int bs); -extern void Super2xSaI_16 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void Super2xSaI_32 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void SuperEagle_16 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void SuperEagle_32 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void _2xSaI_16 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void _2xSaI_32 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void AdMame2x (u8 *srcPtr, u32 srcPitch, /* u8 deltaPtr, */ - u8 *dstPtr, u32 dstPitch, int width, int height); -extern void AdMame2x32 (u8 *srcPtr, u32 srcPitch, /* u8 deltaPtr, */ - u8 *dstPtr, u32 dstPitch, int width, int height); +extern "C" +{ + extern void S2X_configure (int rb, int gb, int bb, int rs, int gs, int bs); + extern int Init_2xSaI (int rb, int gb, int bb, int rs, int gs, int bs); + extern void Super2xSaI_16 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); + extern void Super2xSaI_32 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); + extern void SuperEagle_16 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); + extern void SuperEagle_32 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); + extern void _2xSaI_16 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); + extern void _2xSaI_32 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); + extern void AdMame2x (u8 *srcPtr, u32 srcPitch, /* u8 deltaPtr, */ + u8 *dstPtr, u32 dstPitch, int width, int height); + extern void AdMame2x32 (u8 *srcPtr, u32 srcPitch, /* u8 deltaPtr, */ + u8 *dstPtr, u32 dstPitch, int width, int height); + + extern void hq_init (int rb, int gb, int bb, int rs, int gs, int bs); -extern void hq_init (int rb, int gb, int bb, int rs, int gs, int bs); -extern void _cdecl hq2x_16 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void _cdecl hq2x_32 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void _cdecl hq3x_16 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void _cdecl hq3x_32 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void _cdecl hq4x_16 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void _cdecl hq4x_32 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); + extern void _cdecl hq2x_16 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); + extern void _cdecl hq2x_32 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); + extern void _cdecl hq3x_16 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); + extern void _cdecl hq3x_32 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); + extern void _cdecl hq4x_16 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); + extern void _cdecl hq4x_32 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); +} #define UAE_FILTER_NULL 1 #define UAE_FILTER_SCALE2X 2 diff --git a/include/memory.h b/include/memory.h index 3ef61037..0a4f02ae 100644 --- a/include/memory.h +++ b/include/memory.h @@ -14,8 +14,8 @@ extern int special_mem; #define S_READ 1 #define S_WRITE 2 -extern void *cache_alloc (int); -extern void cache_free (void*); +extern uae_u8 *cache_alloc (int); +extern void cache_free (uae_u8*); #endif int init_shm (void); @@ -345,7 +345,7 @@ extern void mapkick (void); extern void a3000_fakekick (int); extern uaecptr strcpyha_safe (uaecptr dst, const uae_char *src); -extern uae_char *strcpyah_safe (uae_u8 *dst, uaecptr src, int maxsize); +extern uae_char *strcpyah_safe (uae_char *dst, uaecptr src, int maxsize); extern void memcpyha_safe (uaecptr dst, const uae_u8 *src, int size); extern void memcpyha (uaecptr dst, const uae_u8 *src, int size); extern void memcpyah_safe (uae_u8 *dst, uaecptr src, int size); diff --git a/include/moduleripper.h b/include/moduleripper.h index 02e8ad14..5dd3830a 100644 --- a/include/moduleripper.h +++ b/include/moduleripper.h @@ -1,4 +1,3 @@ -extern int prowizard_search (unsigned char *in_data, int in_size); + +extern "C" int prowizard_search (unsigned char *in_data, int in_size); extern void moduleripper (void); -extern FILE *moduleripper_fopen(const char *, const char *); -extern FILE *moduleripper2_fopen(const char *, const char *, const char *, int, int); diff --git a/include/newcpu.h b/include/newcpu.h index dded7b47..563a190c 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -47,8 +47,6 @@ extern int fpp_movem_index2[256]; extern int fpp_movem_next[256]; #endif -struct regstruct; - typedef unsigned long REGPARAM3 cpuop_func (uae_u32) REGPARAM; typedef void REGPARAM3 cpuop_func_ce (uae_u32) REGPARAM; @@ -112,8 +110,7 @@ struct cache040 int count; }; -struct flag_struct regflags; -extern struct regstruct +struct regstruct { uae_u32 regs[16]; @@ -168,7 +165,9 @@ extern struct regstruct int ce020memcycles; evt lastfetch; -} regs, lastint_regs, mmu_backup_regs; +}; + +extern struct regstruct regs; STATIC_INLINE uae_u32 munge24 (uae_u32 x) { diff --git a/include/options.h b/include/options.h index 2f4f2a89..4c08b3af 100644 --- a/include/options.h +++ b/include/options.h @@ -458,92 +458,3 @@ extern struct uae_prefs currprefs, changed_prefs; extern int machdep_init (void); extern void machdep_free (void); - -/* AIX doesn't think it is Unix. Neither do I. */ -#if defined(_ALL_SOURCE) || defined(_AIX) -#undef __unix -#define __unix -#endif - -#define MAX_COLOR_MODES 5 - -/* #define NEED_TO_DEBUG_BADLY */ - -#if !defined(USER_PROGRAMS_BEHAVE) -#define USER_PROGRAMS_BEHAVE 0 -#endif - -/* Some memsets which know that they can safely overwrite some more memory - * at both ends and use that knowledge to align the pointers. */ - -#define QUADRUPLIFY(c) (((c) | ((c) << 8)) | (((c) | ((c) << 8)) << 16)) - -/* When you call this routine, bear in mind that it rounds the bounds and - * may need some padding for the array. */ - -#define fuzzy_memset(p, c, o, l) fuzzy_memset_1 ((p), QUADRUPLIFY (c), (o) & ~3, ((l) + 4) >> 2) -STATIC_INLINE void fuzzy_memset_1 (void *p, uae_u32 c, int offset, int len) -{ - uae_u32 *p2 = (uae_u32 *)((TCHAR *)p + offset); - int a = len & 7; - len >>= 3; - switch (a) { - case 7: p2--; goto l1; - case 6: p2-=2; goto l2; - case 5: p2-=3; goto l3; - case 4: p2-=4; goto l4; - case 3: p2-=5; goto l5; - case 2: p2-=6; goto l6; - case 1: p2-=7; goto l7; - case 0: if (!--len) return; break; - } - - for (;;) { - p2[0] = c; - l1: - p2[1] = c; - l2: - p2[2] = c; - l3: - p2[3] = c; - l4: - p2[4] = c; - l5: - p2[5] = c; - l6: - p2[6] = c; - l7: - p2[7] = c; - - if (!len) - break; - len--; - p2 += 8; - } -} - -/* This one knows it will never be asked to clear more than 32 bytes. Make sure you call this with a - constant for the length. */ -#define fuzzy_memset_le32(p, c, o, l) fuzzy_memset_le32_1 ((p), QUADRUPLIFY (c), (o) & ~3, ((l) + 7) >> 2) -STATIC_INLINE void fuzzy_memset_le32_1 (void *p, uae_u32 c, int offset, int len) -{ - uae_u32 *p2 = (uae_u32 *)((TCHAR *)p + offset); - - switch (len) { - case 9: p2[0] = c; p2[1] = c; p2[2] = c; p2[3] = c; p2[4] = c; p2[5] = c; p2[6] = c; p2[7] = c; p2[8] = c; break; - case 8: p2[0] = c; p2[1] = c; p2[2] = c; p2[3] = c; p2[4] = c; p2[5] = c; p2[6] = c; p2[7] = c; break; - case 7: p2[0] = c; p2[1] = c; p2[2] = c; p2[3] = c; p2[4] = c; p2[5] = c; p2[6] = c; break; - case 6: p2[0] = c; p2[1] = c; p2[2] = c; p2[3] = c; p2[4] = c; p2[5] = c; break; - case 5: p2[0] = c; p2[1] = c; p2[2] = c; p2[3] = c; p2[4] = c; break; - case 4: p2[0] = c; p2[1] = c; p2[2] = c; p2[3] = c; break; - case 3: p2[0] = c; p2[1] = c; p2[2] = c; break; - case 2: p2[0] = c; p2[1] = c; break; - case 1: p2[0] = c; break; - case 0: break; - default: printf("Hit the programmer.\n"); break; - } -} - -#if defined(AMIGA) && defined(__GNUC__) -#include "od-amiga/amiga-kludges.h" -#endif diff --git a/include/readcpu.h b/include/readcpu.h index 47b50782..570f34e8 100644 --- a/include/readcpu.h +++ b/include/readcpu.h @@ -33,11 +33,13 @@ ENUMDECL { i_LPSTOP } ENUMNAME (instrmnem); -extern struct mnemolookup { +struct mnemolookup { instrmnem mnemo; const TCHAR *name; const TCHAR *friendlyname; -} lookuptab[]; +}; + +extern struct mnemolookup lookuptab[]; ENUMDECL { sz_byte, sz_word, sz_long diff --git a/include/sysdeps.h b/include/sysdeps.h index 23083e9a..4382cb72 100644 --- a/include/sysdeps.h +++ b/include/sysdeps.h @@ -22,11 +22,6 @@ #include #include -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef __STDC__ #ifndef _MSC_VER #error "Your compiler is not ANSI. Get a real one." @@ -183,7 +178,7 @@ extern void* q_memcpy(void*,const void*,size_t); /* If char has more then 8 bits, good night. */ typedef unsigned char uae_u8; typedef signed char uae_s8; -typedef unsigned char uae_char; +typedef char uae_char; typedef struct { uae_u8 RGB[3]; } RGB; @@ -249,10 +244,6 @@ extern char *uutf8 (const TCHAR *s); extern TCHAR *utf8u (const char *s); extern void unicode_init (void); -extern void *xmalloc (size_t); -extern void *xcalloc (size_t, size_t); -extern void xfree (const void*); - /* We can only rely on GNU C getting enums right. Mickeysoft VSC++ is known * to have problems, and it's likely that other compilers choke too. */ #ifdef __GNUC__ @@ -489,8 +480,8 @@ extern void gui_message (const TCHAR *,...); extern int gui_message_multibutton (int flags, const TCHAR *format,...); #define write_log_err write_log extern void logging_init (void); -extern void *log_open (const TCHAR *name, int append, int bootlog); -extern void log_close (void *f); +extern FILE *log_open (const TCHAR *name, int append, int bootlog); +extern void log_close (FILE *f); #ifndef O_BINARY @@ -560,6 +551,24 @@ extern void log_close (void *f); #endif -#ifdef __cplusplus -} +#ifndef __cplusplus + +#define xmalloc(T, N) malloc(sizeof (T) * (N)) +#define xcalloc(T, N) calloc(sizeof (T), N) +#define xfree(T) free(T) +#define xrealloc(T, TP, N) realloc(TP, sizeof (T) * (N)) + +#if 0 +extern void *xmalloc (size_t); +extern void *xcalloc (size_t, size_t); +extern void xfree (const void*); #endif + +#else + +#define xmalloc(T, N) static_cast(malloc (sizeof (T) * (N))) +#define xcalloc(T, N) static_cast(calloc (sizeof (T), N)) +#define xrealloc(T, TP, N) static_cast(realloc (TP, sizeof (T) * (N))) +#define xfree(T) free(T) + +#endif \ No newline at end of file diff --git a/include/xwin.h b/include/xwin.h index 19025bf0..3fee419f 100644 --- a/include/xwin.h +++ b/include/xwin.h @@ -28,6 +28,7 @@ extern void desktop_coords (int *dw, int *dh, int *x, int *y, int *w, int *h); extern int vsync_switchmode (int, int); extern void doflashscreen (void); extern int flashscreen; +extern void updatedisplayarea (void); extern void flush_line (int); extern void flush_block (int, int); diff --git a/include/zarchive.h b/include/zarchive.h index 5219ed72..8005dab1 100644 --- a/include/zarchive.h +++ b/include/zarchive.h @@ -73,7 +73,7 @@ struct zvolume struct zarchive_info { - const TCHAR *name; + TCHAR *name; uae_s64 size; int flags; TCHAR *comment; diff --git a/include/zfile.h b/include/zfile.h index 7dda3d78..5ccb9a89 100644 --- a/include/zfile.h +++ b/include/zfile.h @@ -8,6 +8,24 @@ struct zfile; struct zvolume; +struct zdirectory; + +struct fs_dirhandle +{ + int isarch; + union { + struct zdirectory *zd; + struct my_opendir_s *od; + }; +}; +struct fs_filehandle +{ + int isarch; + union { + struct zfile *zf; + struct my_openfile_s *of; + }; +}; typedef int (*zfile_callback)(struct zfile*, void*); @@ -84,13 +102,13 @@ extern struct zvolume *zfile_fopen_archive_root (const TCHAR *filename); extern void zfile_fclose_archive (struct zvolume *zv); extern int zfile_fs_usage_archive (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp); extern int zfile_stat_archive (const TCHAR *path, struct _stat64 *statbuf); -extern void *zfile_opendir_archive (const TCHAR *path); -extern void zfile_closedir_archive (void*); -extern int zfile_readdir_archive (void*, TCHAR*); -extern void zfile_resetdir_archive (void*); +extern struct zdirectory *zfile_opendir_archive (const TCHAR *path); +extern void zfile_closedir_archive (struct zdirectory *); +extern int zfile_readdir_archive (struct zdirectory *, TCHAR*); +extern void zfile_resetdir_archive (struct zdirectory *); extern int zfile_fill_file_attrs_archive (const TCHAR *path, int *isdir, int *flags, TCHAR **comment); -extern uae_s64 zfile_lseek_archive (void *d, uae_s64 offset, int whence); -extern unsigned int zfile_read_archive (void *d, void *b, unsigned int size); -extern void zfile_close_archive (void *d); -extern void *zfile_open_archive (const TCHAR *path, int flags); -extern int zfile_exists_archive(const TCHAR *path, const TCHAR *rel); +extern uae_s64 zfile_lseek_archive (struct zfile *d, uae_s64 offset, int whence); +extern unsigned int zfile_read_archive (struct zfile *d, void *b, unsigned int size); +extern void zfile_close_archive (struct zfile *d); +extern struct zfile *zfile_open_archive (const TCHAR *path, int flags); +extern int zfile_exists_archive (const TCHAR *path, const TCHAR *rel); diff --git a/inprec.c b/inprec.cpp similarity index 100% rename from inprec.c rename to inprec.cpp diff --git a/inputdevice.c b/inputdevice.cpp similarity index 99% rename from inputdevice.c rename to inputdevice.cpp index faa2e0ee..2978a246 100644 --- a/inputdevice.c +++ b/inputdevice.cpp @@ -160,7 +160,7 @@ int inprec_open (TCHAR *fname, int record) zfile_fseek (inprec_zf, 0, SEEK_END); inprec_size = zfile_ftell (inprec_zf); zfile_fseek (inprec_zf, 0, SEEK_SET); - inprec_buffer = inprec_p = xmalloc (inprec_size); + inprec_buffer = inprec_p = xmalloc (uae_u8, inprec_size); zfile_fread (inprec_buffer, inprec_size, 1, inprec_zf); inprec_plastptr = inprec_buffer; id = inprec_pu32(); @@ -179,7 +179,7 @@ int inprec_open (TCHAR *fname, int record) if (record < -1) inprec_div = maxvpos; } else if (record > 0) { - inprec_buffer = inprec_p = xmalloc (inprec_size); + inprec_buffer = inprec_p = xmalloc (uae_u8, inprec_size); inprec_ru32 ('UAE\0'); inprec_ru8 (1); inprec_ru8 (UAEMAJOR); @@ -642,9 +642,9 @@ void write_inputdevice_config (struct uae_prefs *p, struct zfile *f) } } -static int getnum (const TCHAR **pp) +static int getnum (TCHAR **pp) { - const TCHAR *p = *pp; + TCHAR *p = *pp; int v = _tstol (p); while (*p != 0 && *p !='.' && *p != ',') @@ -654,11 +654,11 @@ static int getnum (const TCHAR **pp) *pp = p; return v; } -static TCHAR *getstring (const TCHAR **pp) +static TCHAR *getstring (TCHAR **pp) { int i; static TCHAR str[1000]; - const TCHAR *p = *pp; + TCHAR *p = *pp; if (*p == 0) return 0; @@ -3264,7 +3264,7 @@ static void matchdevices (struct inputdevice_functions *inf, struct uae_input_de if (match >= 0) { j = match; if (j != i) { - struct uae_input_device *tmp = xmalloc (sizeof (struct uae_input_device)); + struct uae_input_device *tmp = xmalloc (struct uae_input_device, 1); memcpy (tmp, &uid[j], sizeof (struct uae_input_device)); memcpy (&uid[j], &uid[i], sizeof (struct uae_input_device)); memcpy (&uid[i], tmp, sizeof (struct uae_input_device)); diff --git a/jit/codegen_x86.c b/jit/codegen_x86.cpp similarity index 100% rename from jit/codegen_x86.c rename to jit/codegen_x86.cpp diff --git a/jit/compemu_fpp.c b/jit/compemu_fpp.cpp similarity index 100% rename from jit/compemu_fpp.c rename to jit/compemu_fpp.cpp diff --git a/jit/compemu_optimizer_x86.c b/jit/compemu_optimizer_x86.cpp similarity index 100% rename from jit/compemu_optimizer_x86.c rename to jit/compemu_optimizer_x86.cpp diff --git a/jit/compemu_raw_x86.c b/jit/compemu_raw_x86.cpp similarity index 99% rename from jit/compemu_raw_x86.c rename to jit/compemu_raw_x86.cpp index e4b52fc1..485b2b4f 100644 --- a/jit/compemu_raw_x86.c +++ b/jit/compemu_raw_x86.cpp @@ -61,13 +61,13 @@ #define STACK_ALIGN 16 #define STACK_OFFSET sizeof(void *) -uae_s8 always_used[]={4,-1}; +uae_u8 always_used[]={4,0xff}; #if defined(__x86_64__) uae_s8 can_byte[]={0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,-1}; uae_s8 can_word[]={0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,-1}; #else -uae_s8 can_byte[]={0,1,2,3,-1}; -uae_s8 can_word[]={0,1,2,3,5,6,7,-1}; +uae_u8 can_byte[]={0,1,2,3,0xff}; +uae_u8 can_word[]={0,1,2,3,5,6,7,0xff}; #endif uae_u8 call_saved[]={0,0,0,0,1,0,0,0}; @@ -1925,7 +1925,7 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except) emit_byte(0xe9); emit_long(ctxPC+len-(uae_u32)target-4); in_handler=1; - target=tmp; + target=(uae_u8*)tmp; } bi=active; while (bi) { @@ -2324,7 +2324,7 @@ x86_get_cpu_vendor(struct cpuinfo_x86 *c) static void cpuid(uae_u32 op, uae_u32 *eax, uae_u32 *ebx, uae_u32 *ecx, uae_u32 *edx) { const int CPUID_SPACE = 4096; - uae_u8* cpuid_space = cache_alloc(CPUID_SPACE); + uae_u8* cpuid_space = (uae_u8*)cache_alloc(CPUID_SPACE); static uae_u32 s_op, s_eax, s_ebx, s_ecx, s_edx; uae_u8* tmp=get_target(); diff --git a/jit/compemu_support.c b/jit/compemu_support.cpp similarity index 99% rename from jit/compemu_support.c rename to jit/compemu_support.cpp index 60c4788f..ffaf5079 100644 --- a/jit/compemu_support.c +++ b/jit/compemu_support.cpp @@ -192,7 +192,7 @@ STATIC_INLINE void remove_from_cl_list(blockinfo* bi) if (cache_tags[cl+1].bi) cache_tags[cl].handler=cache_tags[cl+1].bi->handler_to_use; else - cache_tags[cl].handler=popall_execute_normal; + cache_tags[cl].handler=(cpuop_func*)popall_execute_normal; } STATIC_INLINE void remove_from_list(blockinfo* bi) @@ -292,7 +292,7 @@ STATIC_INLINE void set_dhtu(blockinfo* bi, void* dh) } x=x->next; } - bi->direct_handler_to_use=dh; + bi->direct_handler_to_use=(cpuop_func*)dh; } } @@ -303,7 +303,7 @@ STATIC_INLINE void invalidate_block(blockinfo* bi) bi->optlevel=0; bi->count=currprefs.optcount[0]-1; bi->handler=NULL; - bi->handler_to_use=popall_execute_normal; + bi->handler_to_use=(cpuop_func*)popall_execute_normal; bi->direct_handler=NULL; set_dhtu(bi,bi->direct_pen); bi->needed_flags=0xff; @@ -379,7 +379,7 @@ STATIC_INLINE blockinfo* get_blockinfo_addr_new(void* addr, int setstate) bi=hold_bi[i]; hold_bi[i]=NULL; - bi->pc_p=addr; + bi->pc_p=(uae_u8*)addr; invalidate_block(bi); add_to_active(bi); add_to_cl_list(bi); @@ -541,7 +541,7 @@ int check_prefs_changed_comp (void) ********************************************************************/ //#include "compemu_optimizer.c" -#include "compemu_optimizer_x86.c" +#include "compemu_optimizer_x86.cpp" /******************************************************************** * Functions to emit data into memory, and other general support * @@ -599,7 +599,7 @@ STATIC_INLINE uae_u8* get_target(void) * Getting the information about the target CPU * ********************************************************************/ -#include "compemu_raw_x86.c" +#include "compemu_raw_x86.cpp" /******************************************************************** @@ -5652,13 +5652,13 @@ static void prepare_block(blockinfo* bi) set_target(current_compile_p); align_target(32); - bi->direct_pen=(void*)get_target(); + bi->direct_pen=(cpuop_func*)get_target(); raw_mov_l_rm(0,(uae_u32)&(bi->pc_p)); raw_mov_l_mr((uae_u32)®s.pc_p,0); raw_jmp((uae_u32)popall_execute_normal); align_target(32); - bi->direct_pcc=(void*)get_target(); + bi->direct_pcc=(cpuop_func*)get_target(); raw_mov_l_rm(0,(uae_u32)&(bi->pc_p)); raw_mov_l_mr((uae_u32)®s.pc_p,0); raw_jmp((uae_u32)popall_check_checksum); @@ -5802,7 +5802,7 @@ void build_comp(void) reset_lists(); for (i=0;ipc_p)].handler=(void*)popall_execute_normal; + cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal; cache_tags[cacheline(bi->pc_p)+1].bi=NULL; bi=bi->next; } bi=dormant; while(bi) { - cache_tags[cacheline(bi->pc_p)].handler=(void*)popall_execute_normal; + cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal; cache_tags[cacheline(bi->pc_p)+1].bi=NULL; bi=bi->next; } @@ -5875,13 +5875,13 @@ void flush_icache(uaecptr ptr, int n) if (!bi->handler) { /* invalidated block */ if (bi==cache_tags[cl+1].bi) - cache_tags[cl].handler=popall_execute_normal; - bi->handler_to_use=popall_execute_normal; + cache_tags[cl].handler=(cpuop_func*)popall_execute_normal; + bi->handler_to_use=(cpuop_func*)popall_execute_normal; set_dhtu(bi,bi->direct_pen); } else { if (bi==cache_tags[cl+1].bi) - cache_tags[cl].handler=popall_check_checksum; - bi->handler_to_use=popall_check_checksum; + cache_tags[cl].handler=(cpuop_func*)popall_check_checksum; + bi->handler_to_use=(cpuop_func*)popall_check_checksum; set_dhtu(bi,bi->direct_pcc); } bi2=bi; @@ -5991,7 +5991,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) /* Now aligned at n*32+16 */ bi->handler= - bi->handler_to_use=(void*)get_target(); + bi->handler_to_use=(cpuop_func*)get_target(); raw_cmp_l_mi((uae_u32)®s.pc_p,(uae_u32)pc_hist[0].location); raw_jnz((uae_u32)popall_cache_miss); /* This was 16 bytes on the x86, so now aligned on (n+1)*32 */ @@ -6005,7 +6005,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) was_comp=1; #endif - bi->direct_handler=(void*)get_target(); + bi->direct_handler=(cpuop_func*)get_target(); set_dhtu(bi,bi->direct_handler); current_block_start_target=(uae_u32)get_target(); @@ -6101,7 +6101,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) raw_mov_l_rm(0,(uae_u32)specflags); raw_test_l_rr(0,0); raw_jz_b_oponly(); - branchadd=get_target(); + branchadd=(uae_s8*)get_target(); emit_byte(0); raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles)); raw_jmp((uae_u32)popall_do_nothing); diff --git a/jit/compemu_support_codegen.c b/jit/compemu_support_codegen.cpp similarity index 100% rename from jit/compemu_support_codegen.c rename to jit/compemu_support_codegen.cpp diff --git a/jit/gencomp.c b/jit/gencomp.cpp similarity index 98% rename from jit/gencomp.c rename to jit/gencomp.cpp index fb1c744c..65df0537 100644 --- a/jit/gencomp.c +++ b/jit/gencomp.cpp @@ -1782,7 +1782,7 @@ gen_opcode (unsigned long int opcode) comprintf("\tm68k_pc_offset=0;\n"); comprintf("\tadd_l(PC_P,src);\n"); - comprintf("\tcomp_pc_p=(void*)get_const(PC_P);\n"); + comprintf("\tcomp_pc_p=(uae_u8*)get_const(PC_P);\n"); break; case i_Bcc: comprintf("\tuae_u32 v1,v2;\n"); @@ -1819,7 +1819,7 @@ gen_opcode (unsigned long int opcode) switch(curi->cc) { case 0: /* Unconditional jump */ comprintf("\tmov_l_rr(PC_P,src);\n"); - comprintf("\tcomp_pc_p=(void*)get_const(PC_P);\n"); + comprintf("\tcomp_pc_p=(uae_u8*)get_const(PC_P);\n"); break; case 1: break; /* This is silly! */ case 8: failure; break; /* Work out details! FIXME */ @@ -2869,15 +2869,14 @@ gen_opcode (unsigned long int opcode) } static void -generate_includes (FILE * f) +generate_includes (FILE * f, int bigger) { fprintf (f, "#include \"sysconfig.h\"\n"); fprintf (f, "#if defined(JIT)\n"); fprintf (f, "#include \"sysdeps.h\"\n"); - fprintf (f, "#include \"options.h\"\n"); + if (bigger) + fprintf (f, "#include \"options.h\"\n"); fprintf (f, "#include \"memory.h\"\n"); - fprintf (f, "#include \"custom.h\"\n"); - fprintf (f, "#include \"events.h\"\n"); fprintf (f, "#include \"newcpu.h\"\n"); fprintf (f, "#include \"comptbl.h\"\n"); } @@ -3012,18 +3011,22 @@ generate_one_opcode (int rp, int noflags) comprintf ("return 0;\n"); comprintf ("}\n"); + char name[100] = { 0 }; + for (int k = 0; lookuptab[i].name[k]; k++) + name[k] = lookuptab[i].name[k]; + if (aborted) { - fprintf (stblfile, "{ NULL, %ld, 0x%08x }, /* %s */\n", opcode, flags, lookuptab[i].name); + fprintf (stblfile, "{ NULL, %ld, 0x%08x }, /* %s */\n", opcode, flags, name); com_discard(); } else { if (noflags) { - fprintf (stblfile, "{ op_%lx_%d_comp_nf, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, lookuptab[i].name); + fprintf (stblfile, "{ op_%lx_%d_comp_nf, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, name); fprintf (headerfile, "extern compop_func op_%lx_%d_comp_nf;\n", opcode, postfix); - printf ("unsigned long REGPARAM2 op_%lx_%d_comp_nf(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); + printf ("unsigned long REGPARAM2 op_%lx_%d_comp_nf(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, name); } else { - fprintf (stblfile, "{ op_%lx_%d_comp_ff, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, lookuptab[i].name); + fprintf (stblfile, "{ op_%lx_%d_comp_ff, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, name); fprintf (headerfile, "extern compop_func op_%lx_%d_comp_ff;\n", opcode, postfix); - printf ("unsigned long REGPARAM2 op_%lx_%d_comp_ff(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); + printf ("unsigned long REGPARAM2 op_%lx_%d_comp_ff(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, name); } com_flush(); } @@ -3066,7 +3069,7 @@ generate_func (int noflags) "#define PART_7 1\n" "#define PART_8 1\n" "#endif\n\n" - "extern void setzflg_l();\n" + "extern void setzflg_l(uae_u32);\n" "extern void comp_fpp_opp();\n" "extern void comp_fscc_opp();\n" "extern void comp_fbcc_opp();\n\n"); @@ -3092,10 +3095,10 @@ main (int argc, char **argv) read_table68k (); do_merges (); - opcode_map = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs); - opcode_last_postfix = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs); - opcode_next_clev = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs); - counts = (unsigned long *) xmalloc (65536 * sizeof (unsigned long)); + opcode_map = xmalloc (int, nr_cpuop_funcs); + opcode_last_postfix = xmalloc (int, nr_cpuop_funcs); + opcode_next_clev = xmalloc (int, nr_cpuop_funcs); + counts = xmalloc (unsigned long, 65536); read_counts (); /* It would be a lot nicer to put all in one file (we'd also get rid of @@ -3103,11 +3106,21 @@ main (int argc, char **argv) * I don't dare to touch the 68k version. */ headerfile = fopen ("jit/comptbl.h", "wb"); - stblfile = fopen ("jit/compstbl.c", "wb"); - freopen ("jit/compemu.c", "wb", stdout); - generate_includes (stdout); - generate_includes (stblfile); + fprintf (headerfile, "" \ + "#ifdef NOFLAGS_SUPPORT\n" \ + "/* 68040 */\n" \ + "extern const struct comptbl op_smalltbl_0_nf[];\n" \ + "#endif\n" \ + "extern const struct comptbl op_smalltbl_0_comp_nf[];\n" \ + "extern const struct comptbl op_smalltbl_0_comp_ff[];\n" \ + ""); + + stblfile = fopen ("jit/compstbl.cpp", "wb"); + freopen ("jit/compemu.cpp", "wb", stdout); + + generate_includes (stdout, 1); + generate_includes (stblfile, 0); printf("#include \"compemu.h\"\n"); @@ -3115,10 +3128,10 @@ main (int argc, char **argv) generate_func (noflags); - opcode_map = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs); - opcode_last_postfix = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs); - opcode_next_clev = (int *) xmalloc (sizeof (int) * nr_cpuop_funcs); - counts = (unsigned long *) xmalloc (65536 * sizeof (unsigned long)); + opcode_map = xmalloc (int, nr_cpuop_funcs); + opcode_last_postfix = xmalloc (int, nr_cpuop_funcs); + opcode_next_clev = xmalloc (int, nr_cpuop_funcs); + counts = xmalloc (unsigned long, 65536); read_counts (); noflags=1; generate_func (noflags); diff --git a/keybuf.c b/keybuf.cpp similarity index 99% rename from keybuf.c rename to keybuf.cpp index b0c229f3..5906bb0b 100644 --- a/keybuf.c +++ b/keybuf.cpp @@ -227,7 +227,7 @@ void keybuf_init (void) uae_u8 *save_keyboard (int *len) { uae_u8 *dst, *t; - dst = t = xmalloc (8); + dst = t = xmalloc (uae_u8, 8); save_u32 (getcapslockstate () ? 1 : 0); save_u32 (0); *len = 8; diff --git a/main.c b/main.cpp similarity index 100% rename from main.c rename to main.cpp diff --git a/memory.c b/memory.cpp similarity index 99% rename from memory.c rename to memory.cpp index 217a6d78..65321c7f 100644 --- a/memory.c +++ b/memory.cpp @@ -1444,7 +1444,7 @@ void a3000_fakekick (int map) uae_u8 *fkickmemory = a3000lmemory + allocated_a3000lmem - fkickmem_size; if (fkickmemory[2] == 0x4e && fkickmemory[3] == 0xf9 && fkickmemory[4] == 0x00) { if (!kickstore) - kickstore = xmalloc (fkickmem_size); + kickstore = xmalloc (uae_u8, fkickmem_size); memcpy (kickstore, kickmemory, fkickmem_size); if (fkickmemory[5] == 0xfc) { memcpy (kickmemory, fkickmemory, fkickmem_size / 2); @@ -1539,7 +1539,7 @@ static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksu } if (currprefs.cs_a1000ram) { int off = 0; - a1000_bootrom = xcalloc (262144, 1); + a1000_bootrom = xcalloc (uae_u8, 262144); while (off + i < 262144) { memcpy (a1000_bootrom + off, kickmemory, i); off += i; @@ -1811,7 +1811,7 @@ err: uae_u8 *mapped_malloc (size_t s, TCHAR *file) { - return xmalloc (s); + return xmalloc (uae_u8, s); } void mapped_free (uae_u8 *p) @@ -1911,10 +1911,10 @@ static void add_shmmaps (uae_u32 start, addrbank *what) x = find_shmpiece (base); if (!x) return; - y = xmalloc (sizeof (shmpiece)); + y = xmalloc (shmpiece, 1); *y = *x; base = ((uae_u8 *) NATMEM_OFFSET) + start; - y->native_address = shmat (y->id, base, 0); + y->native_address = (uae_u8*)shmat (y->id, base, 0); if (y->native_address == (void *) -1) { write_log (L"NATMEM: Failure to map existing at %08x (%p)\n", start, base); dumplist (); @@ -1936,7 +1936,7 @@ uae_u8 *mapped_malloc (size_t s, const TCHAR *file) if (!canjit()) { nocanbang (); - return xcalloc (s + 4, 1); + return xcalloc (uae_u8, s + 4); } id = shmget (IPC_PRIVATE, s, 0x1ff, file); @@ -1954,7 +1954,7 @@ uae_u8 *mapped_malloc (size_t s, const TCHAR *file) answer = shmat (id, 0, 0); shmctl (id, IPC_RMID, NULL); if (answer != (void *) -1) { - x = xmalloc (sizeof (shmpiece)); + x = xmalloc (shmpiece, 1); x->native_address = (uae_u8*)answer; x->id = id; x->size = s; @@ -1963,7 +1963,7 @@ uae_u8 *mapped_malloc (size_t s, const TCHAR *file) if (x->next) x->next->prev = x; shm_start = x; - return answer; + return (uae_u8*)answer; } nocanbang (); return mapped_malloc (s, file); @@ -2846,7 +2846,7 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = xmalloc (4 + 4 + 4 + 4 + 4 + 256 + 256 + mem_size); + dstbak = dst = xmalloc (uae_u8, 4 + 4 + 4 + 4 + 4 + 256 + 256 + mem_size); save_u32 (mem_start); save_u32 (mem_size); save_u32 (mem_type); diff --git a/missing.c b/missing.cpp similarity index 97% rename from missing.c rename to missing.cpp index 2c26668d..c63538ad 100644 --- a/missing.c +++ b/missing.cpp @@ -22,6 +22,8 @@ TCHAR *my_strdup (const TCHAR *s) #endif +#if 0 + void *xmalloc (size_t n) { void *a = malloc (n); @@ -39,3 +41,5 @@ void xfree (const void *p) free (p); } + +#endif diff --git a/moduleripper.c b/moduleripper.cpp similarity index 96% rename from moduleripper.c rename to moduleripper.cpp index a8137e1a..6a7817ef 100644 --- a/moduleripper.c +++ b/moduleripper.cpp @@ -46,7 +46,7 @@ void moduleripper (void) size += currprefs.mbresmem_high_size; size += currprefs.z3fastmem_size; size += currprefs.z3fastmem2_size; - buf = p = xmalloc (size); + buf = p = xmalloc (uae_u8, size); if (!buf) return; memcpy (p, chipmemory, currprefs.chipmem_size); @@ -82,6 +82,9 @@ void moduleripper (void) xfree (buf); } +extern "C" +{ + FILE *moduleripper_fopen (const char *aname, const char *amode) { TCHAR tmp2[MAX_DPATH]; @@ -120,6 +123,12 @@ FILE *moduleripper2_fopen (const char *name, const char *mode, const char *aid, return moduleripper_fopen (name, mode); } +void pw_write_log (const char *format,...) +{ +} + +} + #else FILE *moduleripper_fopen (const char *name, const char *mode) diff --git a/native2amiga.c b/native2amiga.cpp similarity index 100% rename from native2amiga.c rename to native2amiga.cpp diff --git a/ncr_scsi.c b/ncr_scsi.cpp similarity index 99% rename from ncr_scsi.c rename to ncr_scsi.cpp index 92e86f7a..749da209 100644 --- a/ncr_scsi.c +++ b/ncr_scsi.cpp @@ -312,7 +312,7 @@ uae_u32 ncr_bget2 (uaecptr addr) return v; } -static addrbank ncr_bank; +extern addrbank ncr_bank; static uae_u32 REGPARAM2 ncr_lget (uaecptr addr) { @@ -488,17 +488,17 @@ void ncr_init (void) z = read_rom (&rd); if (z) { write_log (L"A4091 BOOT ROM %d.%d\n", rd->ver, rd->rev); - rom = (uae_u8*)xmalloc (ROM_SIZE * 4); + rom = xmalloc (uae_u8, ROM_SIZE * 4); for (i = 0; i < ROM_SIZE; i++) { uae_u8 b; - zfile_fread(&b, 1, 1, z); + zfile_fread (&b, 1, 1, z); rom[i * 4 + 0] = b; rom[i * 4 + 2] = b << 4; } zfile_fclose(z); } } else { - romwarning(roms); + romwarning (roms); } map_banks (&ncr_bank, 0xe80000 >> 16, 65536 >> 16, 0); } diff --git a/newcpu.c b/newcpu.cpp similarity index 99% rename from newcpu.c rename to newcpu.cpp index 1b4226bd..17f1f108 100644 --- a/newcpu.c +++ b/newcpu.cpp @@ -82,7 +82,7 @@ static uae_u32 tt0_030, tt1_030, tc_030; static uae_u16 mmusr_030; static struct cache020 caches020[CACHELINES020]; -static struct cache040 caches040[CACHELINES040]; +static struct cache040 caches040[CACHESETS040]; #if COUNT_INSTRS static unsigned long int instrcount[65536]; @@ -472,6 +472,7 @@ void init_m68k (void) } struct regstruct regs, mmu_backup_regs; +struct flag_struct regflags; static struct regstruct regs_backup[16]; static int backup_pointer = 0; static long int m68kpc_offset; @@ -2674,9 +2675,8 @@ STATIC_INLINE int do_specialties (int cycles) do_copper (); if (currprefs.cpu_cycle_exact) { - regs.ipl = regs.ipl_pin; + ipl_fetch (); if (time_for_interrupt ()) { - unset_special (SPCFLAG_INT | SPCFLAG_DOINT); do_interrupt (regs.ipl); } } else { @@ -2722,7 +2722,6 @@ STATIC_INLINE int do_specialties (int cycles) if (currprefs.cpu_cycle_exact) { if (time_for_interrupt ()) { - unset_special (SPCFLAG_INT | SPCFLAG_DOINT); do_interrupt (regs.ipl); } } else { @@ -2832,7 +2831,6 @@ static void m68k_run_1 (void) /* It's really sad to have two almost identical functions for this, but we do it all for performance... :( This version emulates 68000's prefetch "cache" */ -int cpu_cycles; static void m68k_run_1 (void) { struct regstruct *r = ®s; @@ -2886,7 +2884,7 @@ static void m68k_run_1_ce (void) { struct regstruct *r = ®s; - regs.ipl = regs.ipl_pin; + ipl_fetch (); for (;;) { uae_u32 opcode = r->ir; (*cpufunctbl[opcode])(opcode); @@ -2894,7 +2892,6 @@ static void m68k_run_1_ce (void) if (do_specialties (0)) return; } - regs.ipl = regs.ipl_pin; if (!currprefs.cpu_cycle_exact || currprefs.cpu_model > 68000) return; } @@ -3544,7 +3541,7 @@ void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *s { TCHAR *buf; - buf = malloc ((MAX_LINEWIDTH + 1) * cnt * sizeof (TCHAR)); + buf = xmalloc (TCHAR, (MAX_LINEWIDTH + 1) * cnt); if (!buf) return; m68k_disasm_2 (buf, (MAX_LINEWIDTH + 1) * cnt, addr, nextpc, cnt, seaddr, deaddr, 1); @@ -3555,7 +3552,7 @@ void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt) { TCHAR *buf; - buf = malloc ((MAX_LINEWIDTH + 1) * cnt * sizeof (TCHAR)); + buf = xmalloc (TCHAR, (MAX_LINEWIDTH + 1) * cnt); if (!buf) return; m68k_disasm_2 (buf, (MAX_LINEWIDTH + 1) * cnt, addr, nextpc, cnt, NULL, NULL, 0); @@ -3864,7 +3861,7 @@ uae_u8 *save_cpu (int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = xmalloc (1000); + dstbak = dst = xmalloc (uae_u8, 1000); model = currprefs.cpu_model; save_u32 (model); /* MODEL */ save_u32 (0x80000000 | (currprefs.address_space_24 ? 1 : 0)); /* FLAGS */ @@ -3932,7 +3929,7 @@ uae_u8 *save_mmu (int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = xmalloc (1000); + dstbak = dst = xmalloc (uae_u8, 1000); save_u32 (model); /* MODEL */ save_u32 (0); /* FLAGS */ *len = dst - dstbak; diff --git a/nogui.c b/nogui.cpp similarity index 100% rename from nogui.c rename to nogui.cpp diff --git a/od-win32/7zplugin.c b/od-win32/7zplugin.cpp similarity index 100% rename from od-win32/7zplugin.c rename to od-win32/7zplugin.cpp diff --git a/od-win32/ahidsound_dsonly.c b/od-win32/ahidsound_dsonly.cpp similarity index 94% rename from od-win32/ahidsound_dsonly.c rename to od-win32/ahidsound_dsonly.cpp index 5274470e..669dc94c 100644 --- a/od-win32/ahidsound_dsonly.c +++ b/od-win32/ahidsound_dsonly.cpp @@ -12,6 +12,7 @@ #define RECORDBUFFER 50 //survive 9 sec of blocking at 44100 #include "sysconfig.h" +#include "sysdeps.h" #if defined(AHI) @@ -24,7 +25,6 @@ #include #include -#include "sysdeps.h" #include "options.h" #include "audio.h" #include "memory.h" @@ -32,13 +32,13 @@ #include "custom.h" #include "newcpu.h" #include "traps.h" -#include "od-win32/win32.h" #include "sounddep/sound.h" #include "dxwrap.h" #include "win32.h" #include "parser.h" #include "enforcer.h" #include "ahidsound.h" +#include "picasso96_win.h" static long samples, playchannel, intcount; static int record_enabled; @@ -183,8 +183,8 @@ void ahi_close_sound (void) void ahi_updatesound(int force) { HRESULT hr; - int pos; - unsigned int dwBytes1, dwBytes2; + DWORD pos; + DWORD dwBytes1, dwBytes2; LPVOID dwData1, dwData2; static int oldpos; @@ -192,14 +192,14 @@ void ahi_updatesound(int force) oldpos = 0; intcount = 1; INTREQ (0x8000 | 0x2000); - hr = IDirectSoundBuffer_Play (lpDSB2, 0, 0, DSBPLAY_LOOPING); + hr = lpDSB2->Play (0, 0, DSBPLAY_LOOPING); if(hr == DSERR_BUFFERLOST) { - IDirectSoundBuffer_Restore (lpDSB2); - hr = IDirectSoundBuffer_Play (lpDSB2, 0, 0, DSBPLAY_LOOPING); + lpDSB2->Restore (); + hr = lpDSB2->Play (0, 0, DSBPLAY_LOOPING); } } - hr = IDirectSoundBuffer_GetCurrentPosition (lpDSB2, &pos, 0); + hr = lpDSB2->GetCurrentPosition (&pos, 0); if (hr != DSERR_BUFFERLOST) { pos -= ahitweak; if (pos < 0) @@ -218,11 +218,11 @@ void ahi_updatesound(int force) } } - hr = IDirectSoundBuffer_Lock (lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0); + hr = lpDSB2->Lock (oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0); if(hr == DSERR_BUFFERLOST) { write_log (L"AHI: lostbuf %d %x\n", pos, amigablksize); IDirectSoundBuffer_Restore (lpDSB2); - hr = IDirectSoundBuffer_Lock (lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0); + hr = lpDSB2->Lock (oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0); } if(FAILED(hr)) return; @@ -335,7 +335,7 @@ static int ahi_init_sound_win32 (void) return 0; soundneutral = 0; ahisndbufsize = (amigablksize * 4) * NATIVBUFFNUM; // use 4 native buffer - ahisndbuffer = malloc (ahisndbufsize + 32); + ahisndbuffer = xmalloc (uae_u8, ahisndbufsize + 32); if (!ahisndbuffer) return 0; if (sound_devices[currprefs.win32_soundcard].type != SOUND_DEVICE_DS) @@ -495,10 +495,12 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context) case 3: { - LPTSTR pos1,pos2; + LPVOID pos1, pos2; + DWORD t, cur_pos; uaecptr addr; HRESULT hr; - int i, t, todo, byte1, byte2, cur_pos; + int i, todo; + DWORD byte1, byte2; if (!ahi_on) return -2; @@ -506,7 +508,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context) ahi_init_record_win32(); if (record_enabled < 0) return -2; - hr = IDirectSoundCaptureBuffer_GetCurrentPosition(lpDSB2r, &t, &cur_pos); + hr = lpDSB2r->GetCurrentPosition(&t, &cur_pos); if (FAILED(hr)) return -1; @@ -517,7 +519,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context) todo = cur_pos + (RECORDBUFFER * t) - cap_pos; if (todo < t) //if no complete buffer ready exit return -1; - hr = IDirectSoundCaptureBuffer_Lock(lpDSB2r, cap_pos, t, &pos1, &byte1, &pos2, &byte2, 0); + hr = lpDSB2r->Lock(cap_pos, t, &pos1, &byte1, &pos2, &byte2, 0); if (FAILED(hr)) return -1; if ((cap_pos + t) < (t * RECORDBUFFER)) @@ -532,7 +534,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context) addr += 4; } t *= 4; - IDirectSoundCaptureBuffer_Unlock(lpDSB2r, pos1, byte1, pos2, byte2); + lpDSB2r->Unlock(pos1, byte1, pos2, byte2); return (todo - t) / t; } @@ -555,7 +557,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context) case 10: #if 1 if (OpenClipboard (0)) { - clipdat = GetClipboardData (CF_UNICODETEXT); + clipdat = (TCHAR*)GetClipboardData (CF_UNICODETEXT); if (clipdat) { clipsize = _tcslen (clipdat); clipsize++; @@ -585,7 +587,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context) case 12: { #if 1 - TCHAR *s = au (get_real_address (m68k_areg (regs, 0))); + TCHAR *s = au ((char*)get_real_address (m68k_areg (regs, 0))); static LPTSTR p; int slen; @@ -594,9 +596,9 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context) slen = _tcslen (s); if (p) GlobalFree (p); - p = GlobalAlloc (GMEM_MOVEABLE, (slen + 1) * sizeof (TCHAR)); + p = (LPTSTR)GlobalAlloc (GMEM_MOVEABLE, (slen + 1) * sizeof (TCHAR)); if (p) { - TCHAR *p2 = GlobalLock (p); + TCHAR *p2 = (TCHAR*)GlobalLock (p); if (p2) { _tcscpy (p2, s); GlobalUnlock (p); @@ -694,7 +696,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context) char *funcname; m = (HMODULE) m68k_dreg (regs, 1); funcaddr = m68k_areg (regs, 0); - funcname = get_real_address (funcaddr); + funcname = (char*)get_real_address (funcaddr); return (uae_u32) GetProcAddress (m, funcname); } diff --git a/od-win32/ahidsound_new.c b/od-win32/ahidsound_new.cpp similarity index 99% rename from od-win32/ahidsound_new.c rename to od-win32/ahidsound_new.cpp index 944092cf..f7d16fc8 100644 --- a/od-win32/ahidsound_new.c +++ b/od-win32/ahidsound_new.cpp @@ -700,7 +700,7 @@ error: dsahip->chout, dsahip->channellength); dsahip->tmpbuffer_size = 1000000; - dsahip->tmpbuffer = xmalloc (dsahip->tmpbuffer_size); + dsahip->tmpbuffer = xmalloc (uae_u8, dsahip->tmpbuffer_size); if (ahi_debug) write_log (L"AHI: OpenAL initialized: %s\n", sound_devices[dsahip->output].name); @@ -773,7 +773,7 @@ error: { if (dsahip->bits24) { } else { - uae_s16 *dst2 = (uae_u16*)(&dst[idx * och2]); + uae_s16 *dst2 = (uae_s16*)(&dst[idx * och2]); l >>= 8; r >>= 8; if (dc->cs.volume < 0) { @@ -1384,8 +1384,8 @@ error: if (cansurround) ret |= AHISF_KNOWMULTICHANNEL; - dsahip->sample = xcalloc (sizeof (struct dssample), dsahip->sounds); - dsahip->channel = xcalloc (sizeof (struct dschannel), dsahip->channels); + dsahip->sample = xcalloc (struct dssample, dsahip->sounds); + dsahip->channel = xcalloc (struct dschannel, dsahip->channels); for (i = 0; i < dsahip->channels; i++) { struct dschannel *dc = &dsahip->channel[i]; dc->num = i; @@ -1694,7 +1694,7 @@ error: uae_u16 channel = m68k_dreg (regs, 0); uae_u16 sound = m68k_dreg (regs, 1); uae_u32 offset = m68k_dreg (regs, 2); - uae_u32 length = m68k_dreg (regs, 3); + int length = m68k_dreg (regs, 3); uae_u32 audioctrl = m68k_areg (regs, 2); uae_u32 flags = m68k_dreg (regs, 4); struct DSAHI *dsahip = GETAHI; diff --git a/od-win32/ahidsound_new2.c b/od-win32/ahidsound_new2.cpp similarity index 100% rename from od-win32/ahidsound_new2.c rename to od-win32/ahidsound_new2.cpp diff --git a/od-win32/ahidsound_unified.c b/od-win32/ahidsound_unified.cpp similarity index 100% rename from od-win32/ahidsound_unified.c rename to od-win32/ahidsound_unified.cpp diff --git a/od-win32/ahidsoundx_new.c b/od-win32/ahidsoundx_new.cpp similarity index 100% rename from od-win32/ahidsoundx_new.c rename to od-win32/ahidsoundx_new.cpp diff --git a/od-win32/avioutput.c b/od-win32/avioutput.cpp similarity index 97% rename from od-win32/avioutput.c rename to od-win32/avioutput.cpp index b8202d5a..4841d403 100644 --- a/od-win32/avioutput.c +++ b/od-win32/avioutput.cpp @@ -64,8 +64,8 @@ static int videoallocated; int avioutput_width, avioutput_height, avioutput_bits; int avioutput_fps = VBLANK_HZ_PAL; -DWORD avioutput_framelimiter = 0, avioutput_nosoundoutput = 0; -DWORD avioutput_nosoundsync = 1, avioutput_originalsize = 0; +int avioutput_framelimiter = 0, avioutput_nosoundoutput = 0; +int avioutput_nosoundsync = 1, avioutput_originalsize = 0; TCHAR avioutput_filename[MAX_DPATH]; static TCHAR avioutput_filename_tmp[MAX_DPATH]; @@ -147,8 +147,8 @@ static void freeavientry (struct avientry *ae) static struct avientry *allocavientry_audio (uae_u8 *snd, int size) { - struct avientry *ae = xcalloc (sizeof (struct avientry), 1); - ae->lpAudio = xmalloc (size); + struct avientry *ae = xcalloc (struct avientry, 1); + ae->lpAudio = xmalloc (uae_u8, size); memcpy (ae->lpAudio, snd, size); ae->sndsize = size; return ae; @@ -156,10 +156,10 @@ static struct avientry *allocavientry_audio (uae_u8 *snd, int size) static struct avientry *allocavientry_video (void) { - struct avientry *ae = xcalloc (sizeof (struct avientry), 1); - ae->lpbi = xmalloc (lpbisize ()); + struct avientry *ae = xcalloc (struct avientry, 1); + ae->lpbi = (LPBITMAPINFOHEADER)xmalloc (uae_u8, lpbisize ()); memcpy (ae->lpbi, lpbi, lpbisize ()); - ae->lpVideo = calloc (lpbi->biSizeImage, 1); + ae->lpVideo = xcalloc (uae_u8, lpbi->biSizeImage); return ae; } @@ -221,7 +221,7 @@ static void storesettings (UAEREG *avikey) } static void getsettings (UAEREG *avikey) { - DWORD val; + int val; if (regqueryint (avikey, L"NoSoundOutput", &val)) avioutput_nosoundoutput = val; if (regqueryint (avikey, L"NoSoundSync", &val)) @@ -264,8 +264,6 @@ static int AVIOutput_AudioAllocated (void) return pwfxDst ? 1 : 0; } -const static GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}}; - static int AVIOutput_AllocateAudio (void) { MMRESULT err; @@ -305,7 +303,7 @@ static int AVIOutput_AllocateAudio (void) } } - if (!(pwfxDst = (LPWAVEFORMATEX) xmalloc (wfxMaxFmtSize))) + if (!(pwfxDst = (LPWAVEFORMATEX)xmalloc (uae_u8, wfxMaxFmtSize))) return 0; // set the initial destination format to match source @@ -365,7 +363,7 @@ static int AVIOutput_ValidateAudio (WAVEFORMATEX *wft, TCHAR *name, int len) static int AVIOutput_GetAudioFromRegistry (WAVEFORMATEX *wft) { - DWORD ss; + int ss; int ok = 0; UAEREG *avikey; @@ -504,7 +502,7 @@ static int AVIOutput_AllocateVideo (void) avioutput_bits = 24; if (avioutput_bits > 24) avioutput_bits = 24; - lpbi = xcalloc (lpbisize (), 1); + lpbi = (LPBITMAPINFOHEADER)xcalloc (uae_u8, lpbisize ()); lpbi->biSize = sizeof (BITMAPINFOHEADER); lpbi->biWidth = avioutput_width; lpbi->biHeight = avioutput_height; @@ -534,7 +532,7 @@ static void AVIOutput_FreeCOMPVARS (COMPVARS *pcv) static int AVIOutput_GetCOMPVARSFromRegistry (COMPVARS *pcv) { UAEREG *avikey; - DWORD ss; + int ss; int ok = 0; avikey = openavikey (); @@ -550,7 +548,7 @@ static int AVIOutput_GetCOMPVARSFromRegistry (COMPVARS *pcv) pcv->cbState = 0; if (regquerydatasize (avikey, L"VideoConfigurationState", &ss)) { if (ss > 0) { - LPBYTE state = xmalloc (ss); + LPBYTE state = xmalloc (BYTE, ss); if (regquerydata (avikey, L"VideoConfigurationState", state, &ss)) { pcv->hic = ICOpen (pcv->fccType, pcv->fccHandler, ICMODE_COMPRESS); if (pcv->hic) { @@ -635,7 +633,7 @@ int AVIOutput_ChooseVideoCodec (HWND hwnd, TCHAR *s, int len) ss = ICGetState (pcompvars->hic, NULL, 0); if (ss > 0) { DWORD err; - state = xmalloc (ss); + state = xmalloc (uae_u8, ss); err = ICGetState (pcompvars->hic, state, ss); if (err < 0) { ss = 0; @@ -645,7 +643,7 @@ int AVIOutput_ChooseVideoCodec (HWND hwnd, TCHAR *s, int len) ss = 0; } if (ss == 0) - state = xmalloc (1); + state = xmalloc (uae_u8, 1); avikey = openavikey (); if (avikey) { regsetdata (avikey, L"VideoConfigurationState", state, ss); @@ -712,7 +710,8 @@ static void AVIOuput_AVIWriteAudio (uae_u8 *sndbuffer, int sndbufsize) static int AVIOutput_AVIWriteAudio_Thread (struct avientry *ae) { - DWORD dwOutputBytes = 0, written = 0, swritten = 0; + DWORD dwOutputBytes = 0; + LONG written = 0, swritten = 0; unsigned int err; uae_u8 *lpAudio = NULL; @@ -725,7 +724,7 @@ static int AVIOutput_AVIWriteAudio_Thread (struct avientry *ae) goto error; } - if (!(lpAudio = xmalloc (dwOutputBytes))) + if (!(lpAudio = xmalloc (uae_u8, dwOutputBytes))) goto error; ash.cbStruct = sizeof (ACMSTREAMHEADER); @@ -816,7 +815,7 @@ static int getFromDC (struct avientry *avie) // create a memory device context compatible with the application's current screen hdcMem = CreateCompatibleDC (hdc); hbitmap = CreateCompatibleBitmap (hdc, avioutput_width, avioutput_height); - hbitmapOld = SelectObject (hdcMem, hbitmap); + hbitmapOld = (HBITMAP)SelectObject (hdcMem, hbitmap); // probably not the best idea to use slow GDI functions for this, // locking the surfaces and copying them by hand would be more efficient perhaps // draw centered in frame @@ -939,7 +938,7 @@ void AVIOutput_WriteVideo (void) static int AVIOutput_AVIWriteVideo_Thread (struct avientry *ae) { - DWORD written = 0; + LONG written = 0; unsigned int err; if (avioutput_video) { @@ -1289,7 +1288,7 @@ void AVIOutput_Initialize (void) InitializeCriticalSection (&AVIOutput_CriticalSection); cs_allocated = 1; - pcompvars = xcalloc (sizeof (COMPVARS), 1); + pcompvars = xcalloc (COMPVARS, 1); if (!pcompvars) return; pcompvars->cbSize = sizeof (COMPVARS); diff --git a/od-win32/avioutput.h b/od-win32/avioutput.h index 72ad2cc5..7b626db1 100644 --- a/od-win32/avioutput.h +++ b/od-win32/avioutput.h @@ -10,9 +10,9 @@ extern int avioutput_video, avioutput_audio, avioutput_enabled, avioutput_reques extern int avioutput_width, avioutput_height, avioutput_bits; extern int avioutput_fps; -extern DWORD avioutput_framelimiter, avioutput_nosoundoutput; -extern DWORD avioutput_nosoundsync, avioutput_originalsize; -extern DWORD screenshot_originalsize; +extern int avioutput_framelimiter, avioutput_nosoundoutput; +extern int avioutput_nosoundsync, avioutput_originalsize; +extern int screenshot_originalsize; extern TCHAR avioutput_filename[MAX_DPATH]; diff --git a/od-win32/blkdev_win32_aspi.c b/od-win32/blkdev_win32_aspi.cpp similarity index 98% rename from od-win32/blkdev_win32_aspi.c rename to od-win32/blkdev_win32_aspi.cpp index 210e54ce..74a83bf6 100644 --- a/od-win32/blkdev_win32_aspi.c +++ b/od-win32/blkdev_win32_aspi.cpp @@ -31,7 +31,7 @@ static DWORD (_cdecl *pfnSendASPI32Command)(LPSRB); static BOOL (_cdecl *pfnGetASPI32Buffer)(PASPI32BUFF); static BOOL (_cdecl *pfnFreeASPI32Buffer)(PASPI32BUFF); static BOOL (_cdecl *pfnTranslateASPI32Address)(PDWORD, PDWORD); -static HANDLE hAspiLib; +static HMODULE hAspiLib; static int scanphase; struct scsi_info { @@ -55,7 +55,7 @@ static int getversion(const TCHAR *name, VS_FIXEDFILEINFO *ver) dwFileVersionInfoSize = GetFileVersionInfoSize(name, &dwVersionHandle); if (dwFileVersionInfoSize) { - if (lpFileVersionData = calloc(1, dwFileVersionInfoSize)) { + if (lpFileVersionData = xcalloc(uae_u8, dwFileVersionInfoSize)) { if (GetFileVersionInfo(name, dwVersionHandle, dwFileVersionInfoSize, lpFileVersionData)) { VS_FIXEDFILEINFO *vsFileInfo = NULL; UINT uLen; @@ -77,7 +77,7 @@ static int getversion(const TCHAR *name, VS_FIXEDFILEINFO *ver) return ok; } -const TCHAR *get_aspi_path(int aspitype) +const TCHAR *get_aspi_path (int aspitype) { static int nero, adaptec, frog; static TCHAR path_nero[MAX_DPATH]; @@ -157,8 +157,8 @@ static int ha_inquiry (SCSI *scgp, int id, SRB_HAInquiry *ip) Status = pfnSendASPI32Command((LPSRB)ip); if (log_scsi) { - TCHAR *s1 = au (ip->HA_ManagerId); - TCHAR *s2 = au (ip->HA_Identifier); + TCHAR *s1 = au ((char*)ip->HA_ManagerId); + TCHAR *s2 = au ((char*)ip->HA_Identifier); write_log (L"ASPI: S=%d ha=%d, ID=%d, M='%s', Id='%s'\n", Status, ip->HA_Count, ip->HA_SCSI_ID, s1, s2); xfree (s2); @@ -335,7 +335,7 @@ static SCSI *scsi_smalloc(void) scgp->scmd = (struct scg_cmd *)malloc(sizeof(struct scg_cmd)); if (scgp->scmd == NULL) goto err; - scgp->errstr = malloc(SCSI_ERRSTR_SIZE); + scgp->errstr = xmalloc(char, SCSI_ERRSTR_SIZE); if (scgp->errstr == NULL) goto err; scgp->errptr = scgp->errbeg = scgp->errstr; @@ -579,7 +579,7 @@ static int scsicmd(SCSI *scgp) s.SRB_Target = scg_target(scgp); /* Target SCSI ID */ s.SRB_Lun = scg_lun(scgp); /* Target SCSI LUN */ s.SRB_BufLen = sp->size; /* # of bytes transferred */ - s.SRB_BufPointer= sp->addr; /* pointer to data buffer */ + s.SRB_BufPointer= (BYTE*)sp->addr; /* pointer to data buffer */ s.SRB_CDBLen = sp->cdb_len; /* SCSI command length */ s.SRB_PostProc = Event; /* Post proc event */ s.SRB_SenseLen = SENSE_LEN; /* Lenght of sense buffer */ @@ -728,7 +728,7 @@ static void scan_scsi_bus (SCSI *scgp, int flags) write_log (L"]"); if (use) { unitcnt++; - cis->buf = malloc (DEVICE_SCSI_BUFSIZE); + cis->buf = xmalloc (uae_u8, DEVICE_SCSI_BUFSIZE); cis->scsibus = scgp->addr.scsibus; cis->target = scgp->addr.target; cis->lun = scgp->addr.lun; diff --git a/od-win32/blkdev_win32_ioctl.c b/od-win32/blkdev_win32_ioctl.cpp similarity index 99% rename from od-win32/blkdev_win32_ioctl.c rename to od-win32/blkdev_win32_ioctl.cpp index 4f800342..731d2c65 100644 --- a/od-win32/blkdev_win32_ioctl.c +++ b/od-win32/blkdev_win32_ioctl.cpp @@ -287,7 +287,7 @@ static int cdda_openwav (struct dev_info_ioctl *ciw) static void *cdda_play (void *v) { DWORD len; - struct dev_info_ioctl *ciw = v; + struct dev_info_ioctl *ciw = (struct dev_info_ioctl*)v; int unitnum = ciw32 - ciw; int cdda_pos; int num_sectors = CDDA_BUFFERS; @@ -311,7 +311,7 @@ static void *cdda_play (void *v) Sleep (10); oldplay = -1; - p = VirtualAlloc (NULL, 2 * num_sectors * 4096, MEM_COMMIT, PAGE_READWRITE); + p = (uae_u8*)VirtualAlloc (NULL, 2 * num_sectors * 4096, MEM_COMMIT, PAGE_READWRITE); px[0] = p; px[1] = p + num_sectors * 4096; bufon[0] = bufon[1] = 0; @@ -325,7 +325,7 @@ static void *cdda_play (void *v) for (i = 0; i < 2; i++) { memset (&whdr[i], 0, sizeof (WAVEHDR)); whdr[i].dwBufferLength = 2352 * num_sectors; - whdr[i].lpData = px[i]; + whdr[i].lpData = (LPSTR)px[i]; mmr = waveOutPrepareHeader (ciw->cdda_wavehandle, &whdr[i], sizeof (WAVEHDR)); if (mmr != MMSYSERR_NOERROR) { write_log (L"CDDA: waveOutPrepareHeader %d:%d\n", i, mmr); @@ -1073,7 +1073,7 @@ static int sys_cddev_open (int unitnum) ciw->cdda_volume = 0xffff; ciw->cdda_volume_main = currprefs.sound_volume; /* buffer must be page aligned for device access */ - ciw->tempbuffer = VirtualAlloc (NULL, IOCTL_DATA_BUFFER, MEM_COMMIT, PAGE_READWRITE); + ciw->tempbuffer = (uae_u8*)VirtualAlloc (NULL, IOCTL_DATA_BUFFER, MEM_COMMIT, PAGE_READWRITE); if (!ciw->tempbuffer) { write_log (L"IOCTL: failed to allocate buffer"); return 1; diff --git a/od-win32/blkdev_win32_spti.c b/od-win32/blkdev_win32_spti.cpp similarity index 95% rename from od-win32/blkdev_win32_spti.c rename to od-win32/blkdev_win32_spti.cpp index 923ca7c8..0ac18c1f 100644 --- a/od-win32/blkdev_win32_spti.c +++ b/od-win32/blkdev_win32_spti.cpp @@ -50,7 +50,7 @@ static int unitcnt = 0; struct dev_info_spti { TCHAR *drvpath; TCHAR *name; - TCHAR *inquirydata; + uae_u8 *inquirydata; TCHAR *ident; int mediainserted; HANDLE handle; @@ -74,7 +74,7 @@ static int doscsi (int unitnum, SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER *swb, int * if (log_scsi) { write_log (L"SCSI, H=%X:%d:%d:%d:%d: ", di->handle, di->bus, di->path, di->target, di->lun); scsi_log_before (swb->spt.Cdb, swb->spt.CdbLength, - swb->spt.DataIn == SCSI_IOCTL_DATA_OUT ? swb->spt.DataBuffer : 0,swb->spt.DataTransferLength); + swb->spt.DataIn == SCSI_IOCTL_DATA_OUT ? (uae_u8*)swb->spt.DataBuffer : NULL, swb->spt.DataTransferLength); } gui_flicker_led (LED_CD, unitnum, 1); swb->spt.ScsiStatus = 0; @@ -93,10 +93,10 @@ static int doscsi (int unitnum, SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER *swb, int * write_log (L"SCSI ERROR, H=%X:%d:%d:%d:%d: ", di->handle, di->bus, di->path, di->target, di->lun); write_log (L"Status = %d, Error code = %d, LastError=%d\n", status, swb->spt.ScsiStatus, lasterror); scsi_log_before (swb->spt.Cdb, swb->spt.CdbLength, - swb->spt.DataIn == SCSI_IOCTL_DATA_OUT ? swb->spt.DataBuffer : 0,swb->spt.DataTransferLength); + swb->spt.DataIn == SCSI_IOCTL_DATA_OUT ? (uae_u8*)swb->spt.DataBuffer : 0,swb->spt.DataTransferLength); } if (log_scsi) - scsi_log_after (swb->spt.DataIn == SCSI_IOCTL_DATA_IN ? swb->spt.DataBuffer : 0, swb->spt.DataTransferLength, + scsi_log_after (swb->spt.DataIn == SCSI_IOCTL_DATA_IN ? (uae_u8*)swb->spt.DataBuffer : NULL, swb->spt.DataTransferLength, swb->SenseBuf, swb->spt.SenseInfoLength); if (swb->spt.SenseInfoLength > 0 && (swb->SenseBuf[0] == 0 || swb->SenseBuf[0] == 1)) swb->spt.SenseInfoLength = 0; /* 0 and 1 = success, not error.. */ @@ -281,9 +281,10 @@ static void checkcapabilities (int unitnum) { struct dev_info_spti *di = &dev_info[unitnum]; STORAGE_ADAPTER_DESCRIPTOR desc; - STORAGE_PROPERTY_QUERY query = { 0 }; + STORAGE_PROPERTY_QUERY query; DWORD ret, status; + memset (&query, 0, sizeof STORAGE_PROPERTY_QUERY); query.PropertyId = StorageAdapterProperty; query.QueryType = PropertyStandardQuery; status = DeviceIoControl (di->handle, IOCTL_STORAGE_QUERY_PROPERTY, @@ -395,13 +396,13 @@ int open_scsi_device (int unitnum) if (!di) return 0; if (di->bus >= 0) { - dev = xmalloc (100); + dev = xmalloc (TCHAR, 100); _stprintf (dev, L"\\\\.\\Scsi%d:", di->bus); } else { dev = my_strdup (di->drvpath); } if (!di->scsibuf) - di->scsibuf = VirtualAlloc (NULL, DEVICE_SCSI_BUFSIZE, MEM_COMMIT, PAGE_READWRITE); + di->scsibuf = (uae_u8*)VirtualAlloc (NULL, DEVICE_SCSI_BUFSIZE, MEM_COMMIT, PAGE_READWRITE); h = CreateFile(dev,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL); di->handle = h; if (h == INVALID_HANDLE_VALUE) { @@ -417,7 +418,7 @@ int open_scsi_device (int unitnum) return 0; } inqdata[INQUIRY_SIZE] = 0; - di->name = my_strdup_ansi (inqdata + 8); + di->name = my_strdup_ansi ((char*)inqdata + 8); if (di->type == INQ_ROMD) { dev_info[unitnum].mediainserted = mediacheck (unitnum); write_log (L"SPTI: unit %d opened [%s], %s, '%s'\n", unitnum, @@ -428,7 +429,7 @@ int open_scsi_device (int unitnum) write_log (L"SPTI: unit %d, type %d, '%s'\n", unitnum, di->type, di->name); } - di->inquirydata = xmalloc (INQUIRY_SIZE); + di->inquirydata = xmalloc (uae_u8, INQUIRY_SIZE); memcpy (di->inquirydata, inqdata, INQUIRY_SIZE); xfree (dev); return 1; @@ -573,7 +574,7 @@ static int getCDROMProperty (int idx, HDEVINFO DevInfo, const GUID *guid) } interfaceDetailDataSize = reqSize; - interfaceDetailData = malloc (interfaceDetailDataSize); + interfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)xmalloc (uae_u8, interfaceDetailDataSize); if (interfaceDetailData == NULL) return FALSE; interfaceDetailData->cbSize = sizeof (SP_INTERFACE_DEVICE_DETAIL_DATA); @@ -611,7 +612,7 @@ static void scanscsi (void) int idx; TCHAR DeviceName[256]; - AdapterInfo = xmalloc (SCSI_INFO_BUFFER_SIZE) ; + AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)xmalloc (uae_u8, SCSI_INFO_BUFFER_SIZE); if (AdapterInfo == NULL) return; diff --git a/od-win32/bsdsock.c b/od-win32/bsdsock.cpp similarity index 98% rename from od-win32/bsdsock.c rename to od-win32/bsdsock.cpp index 1a48e181..4ebd2540 100644 --- a/od-win32/bsdsock.c +++ b/od-win32/bsdsock.cpp @@ -68,11 +68,11 @@ struct bsdsockdata { HANDLE hSockReqHandled; CRITICAL_SECTION csSigQueueLock; CRITICAL_SECTION SockThreadCS; - DWORD threadid; + unsigned int threadid; WSADATA wsbData; volatile HANDLE hGetThreads[MAX_GET_THREADS]; - volatile struct threadargs threadGetargs[MAX_GET_THREADS]; + struct threadargs threadGetargs[MAX_GET_THREADS]; volatile int threadGetargs_inuse[MAX_GET_THREADS]; volatile HANDLE hGetEvents[MAX_GET_THREADS]; @@ -147,7 +147,7 @@ static int mySockStartup(void) TCHAR *ss; if (!bsd) { - bsd = calloc (sizeof (struct bsdsockdata), 1); + bsd = xcalloc (struct bsdsockdata, 1); for (i = 0; i < MAX_GET_THREADS; i++) threadindextable[i] = i; } @@ -201,7 +201,7 @@ int init_socket_layer (void) wc.hInstance = hInst; wc.hIcon = LoadIcon (GetModuleHandle (NULL), MAKEINTRESOURCE (IDI_APPICON)); wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hbrBackground = GetStockObject (BLACK_BRUSH); + wc.hbrBackground = (HBRUSH)GetStockObject (BLACK_BRUSH); wc.lpszMenuName = 0; wc.lpszClassName = L"SocketFun"; RegisterClass(&wc); @@ -315,7 +315,7 @@ int host_sbinit(TrapContext *context, SB) if ((sb->hEvent = CreateEvent(NULL,FALSE,FALSE,NULL)) == NULL) return 0; - sb->mtable = calloc(sb->dtablesize, sizeof(*sb->mtable)); + sb->mtable = xcalloc(unsigned int, sb->dtablesize); return 1; } @@ -1016,7 +1016,7 @@ void host_connect(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 na void host_sendto (TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen) { SOCKET s; - uae_char *realpt; + char *realpt; unsigned int wMsg; uae_char buf[MAXADDRLEN]; int iCut; @@ -1033,7 +1033,7 @@ void host_sendto (TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len if (s != INVALID_SOCKET) { if (!addr_valid (L"host_sendto1", msg, 4)) return; - realpt = get_real_address (msg); + realpt = (char*)get_real_address (msg); if (to) { if (tolen > sizeof buf) { @@ -1199,7 +1199,7 @@ void host_recvfrom(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 le if (s != INVALID_SOCKET) { if (!addr_valid (L"host_recvfrom1", msg, 4)) return; - realpt = get_real_address (msg); + realpt = (char*)get_real_address (msg); if (addr) { if (!addr_valid (L"host_recvfrom1", addrlen, 4)) @@ -1987,11 +1987,11 @@ uae_u32 host_Inet_NtoA(TrapContext *context, SB, uae_u32 in) uae_u32 host_inet_addr(uae_u32 cp) { uae_u32 addr; - uae_char *cp_rp; + char *cp_rp; if (!addr_valid (L"host_inet_addr", cp, 4)) return 0; - cp_rp = get_real_address (cp); + cp_rp = (char*)get_real_address (cp); addr = htonl(inet_addr(cp_rp)); @@ -2025,11 +2025,11 @@ static unsigned int thread_get2 (void *indexp) { int index = *((int*)indexp); unsigned int result = 0; - volatile struct threadargs *args; + struct threadargs *args; uae_u32 name; uae_u32 namelen; long addrtype; - uae_char *name_rp; + char *name_rp; SB; while (bsd->hGetEvents[index]) { @@ -2054,7 +2054,7 @@ static unsigned int thread_get2 (void *indexp) namelen = args->args3; addrtype = args->args4; if (addr_valid (L"thread_get1", name, 1)) - name_rp = get_real_address (name); + name_rp = (char*)get_real_address (name); else name_rp = ""; @@ -2085,7 +2085,7 @@ static unsigned int thread_get2 (void *indexp) name = args->args2; if (addr_valid (L"thread_get2", name, 1)) - name_rp = get_real_address (name); + name_rp = (char*)get_real_address (name); else name_rp = ""; proto = getprotobyname (name_rp); @@ -2106,7 +2106,7 @@ static unsigned int thread_get2 (void *indexp) uae_u32 nameport; uae_u32 proto; uae_u32 type; - uae_char *proto_rp = 0; + char *proto_rp = 0; struct servent *serv; nameport = args->args2; @@ -2115,14 +2115,14 @@ static unsigned int thread_get2 (void *indexp) if (proto) { if (addr_valid (L"thread_get3", proto, 1)) - proto_rp = get_real_address (proto); + proto_rp = (char*)get_real_address (proto); } if (type) { serv = getservbyport(nameport, proto_rp); } else { if (addr_valid (L"thread_get4", nameport, 1)) - name_rp = get_real_address (nameport); + name_rp = (char*)get_real_address (nameport); serv = getservbyname(name_rp, proto_rp); } if (bsd->threadGetargs_inuse[index] != -1) { @@ -2133,7 +2133,7 @@ static unsigned int thread_get2 (void *indexp) BSDTRACE((L"failed (%d) - ", sb->sb_errno)); } else { bsdsocklib_seterrno(sb, 0); - memcpy(args->buf, serv, sizeof(struct servent)); + memcpy(args->buf, serv, sizeof (struct servent)); } } } @@ -2219,7 +2219,7 @@ void host_gethostbynameaddr (TrapContext *context, SB, uae_u32 name, uae_u32 nam HOSTENT *h; int size, numaliases = 0, numaddr = 0; uae_u32 aptr; - uae_char *name_rp; + char *name_rp; int i; struct threadargs args; volatile struct threadargs *argsp; @@ -2238,7 +2238,7 @@ void host_gethostbynameaddr (TrapContext *context, SB, uae_u32 name, uae_u32 nam name_rp = ""; if (addr_valid (L"host_gethostbynameaddr", name, 1)) - name_rp = get_real_address (name); + name_rp = (char*)get_real_address (name); if (addrtype == -1) { BSDTRACE((L"gethostbyname(%s) -> ",name_rp)); @@ -2337,14 +2337,14 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name) PROTOENT *p; int size, numaliases = 0; uae_u32 aptr; - uae_char *name_rp; + char *name_rp; int i; struct threadargs args; volatile struct threadargs *argsp; name_rp = ""; if (addr_valid (L"host_gethostbynameaddr", name, 1)) - name_rp = get_real_address (name); + name_rp = (char*)get_real_address (name); BSDTRACE((L"getprotobyname(%s) -> ",name_rp)); @@ -2422,14 +2422,14 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32 if (proto) { if (addr_valid (L"host_getservbynameport1", proto, 1)) - proto_rp = au (get_real_address (proto)); + proto_rp = au ((char*)get_real_address (proto)); } if (type) { BSDTRACE((L"getservbyport(%d,%s) -> ",nameport, proto_rp ? proto_rp : L"NULL")); } else { if (addr_valid (L"host_getservbynameport2", nameport, 1)) - name_rp = au (get_real_address (nameport)); + name_rp = au ((char*)get_real_address (nameport)); BSDTRACE((L"getservbyname(%s,%s) -> ",name_rp, proto_rp ? proto_rp : L"NULL")); } @@ -2500,7 +2500,7 @@ uae_u32 host_gethostname(uae_u32 name, uae_u32 namelen) { if (!addr_valid (L"host_gethostname", name, namelen)) return -1; - return gethostname(get_real_address (name),namelen); + return gethostname ((char*)get_real_address (name),namelen); } #endif diff --git a/od-win32/build68k_msvc/build68k_msvc.rc b/od-win32/build68k_msvc/build68k_msvc.rc deleted file mode 100644 index 3eee795f..00000000 --- a/od-win32/build68k_msvc/build68k_msvc.rc +++ /dev/null @@ -1,61 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/od-win32/build68k_msvc/build68k_msvc.vcproj b/od-win32/build68k_msvc/build68k_msvc.vcproj index a783e62f..86f80606 100644 --- a/od-win32/build68k_msvc/build68k_msvc.vcproj +++ b/od-win32/build68k_msvc/build68k_msvc.vcproj @@ -66,8 +66,8 @@ /> @@ -156,8 +156,8 @@ /> @@ -247,8 +247,8 @@ /> @@ -337,8 +337,8 @@ /> @@ -384,7 +384,7 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > diff --git a/od-win32/build68k_msvc/build68k_msvc.vcxproj b/od-win32/build68k_msvc/build68k_msvc.vcxproj index e0f6b0da..1acddfe4 100644 --- a/od-win32/build68k_msvc/build68k_msvc.vcxproj +++ b/od-win32/build68k_msvc/build68k_msvc.vcxproj @@ -99,8 +99,8 @@ 0x0409 - deleting cpudefs.c - del ..\..\cpudefs.c + deleting cpudefs.cpp + del ..\..\cpudefs.cpp /MACHINE:I386 %(AdditionalOptions) @@ -113,8 +113,10 @@ - creating cpudefs.c - build68k.exe >..\..\cpudefs.c <..\..\table68k + creating cpudefs.cpp + build68k.exe >..\..\cpudefs.cpp <..\..\table68k +del build68k.exe + @@ -248,7 +250,7 @@ - + diff --git a/od-win32/build68k_msvc/build68k_msvc.vcxproj.filters b/od-win32/build68k_msvc/build68k_msvc.vcxproj.filters index 47fe46b3..919edbea 100644 --- a/od-win32/build68k_msvc/build68k_msvc.vcxproj.filters +++ b/od-win32/build68k_msvc/build68k_msvc.vcxproj.filters @@ -7,7 +7,7 @@ - + Source Files diff --git a/od-win32/caps/caps_win32.c b/od-win32/caps/caps_win32.cpp similarity index 99% rename from od-win32/caps/caps_win32.c rename to od-win32/caps/caps_win32.cpp index e03ea37f..a1528ec1 100644 --- a/od-win32/caps/caps_win32.c +++ b/od-win32/caps/caps_win32.cpp @@ -4,11 +4,12 @@ #ifdef CAPS +#include + #include "caps_win32.h" #include "zfile.h" #include "gui.h" #include "win32.h" -#include #include "ComType.h" #include "CapsAPI.h" @@ -114,7 +115,7 @@ int caps_loadimage (struct zfile *zf, int drv, int *num_tracks) zfile_fseek (zf, 0, SEEK_END); len = zfile_ftell (zf); zfile_fseek (zf, 0, SEEK_SET); - buf = xmalloc (len); + buf = xmalloc (uae_u8, len); if (!buf) return 0; if (zfile_fread (buf, len, 1, zf) == 0) diff --git a/od-win32/clipboard_win32.c b/od-win32/clipboard_win32.cpp similarity index 96% rename from od-win32/clipboard_win32.c rename to od-win32/clipboard_win32.cpp index add57689..773381c9 100644 --- a/od-win32/clipboard_win32.c +++ b/od-win32/clipboard_win32.cpp @@ -75,7 +75,7 @@ static uae_char *pctoamiga (const uae_char *txt) int i, j; len = strlen (txt) + 1; - txt2 = xmalloc (len); + txt2 = xmalloc (uae_char, len); j = 0; for (i = 0; i < len; i++) { uae_char c = txt[i]; @@ -86,7 +86,7 @@ static uae_char *pctoamiga (const uae_char *txt) return txt2; } -static int parsecsi (const uae_char *txt, int off, int len) +static int parsecsi (const char *txt, int off, int len) { while (off < len) { if (txt[off] >= 0x40) @@ -96,7 +96,7 @@ static int parsecsi (const uae_char *txt, int off, int len) return off; } -static TCHAR *amigatopc (const uae_u8 *txt) +static TCHAR *amigatopc (const char *txt) { int i, j, cnt; int len, pc; @@ -115,7 +115,7 @@ static TCHAR *amigatopc (const uae_u8 *txt) } if (pc) return my_strdup_ansi (txt); - txt2 = xcalloc (len + cnt, 1); + txt2 = xcalloc (char, len + cnt); j = 0; for (i = 0; i < len; i++) { uae_char c = txt[i]; @@ -161,7 +161,7 @@ static void to_iff_text (TCHAR *pctxt) b[18] = size >> 8; b[19] = size >> 0; to_amiga_size = sizeof b + txtlen + (txtlen & 1); - to_amiga = xcalloc (to_amiga_size, 1); + to_amiga = xcalloc (uae_u8, to_amiga_size); memcpy (to_amiga, b, sizeof b); memcpy (to_amiga + sizeof b, txt, txtlen); to_amiga_start (); @@ -199,7 +199,7 @@ static void from_iff_text (uaecptr ftxt, uae_u32 len) if (!memcmp (addr, "CHRS", 4) && csize) { int prevsize = txtsize; txtsize += csize; - txt = realloc (txt, txtsize + 1); + txt = xrealloc (char, txt, txtsize + 1); memcpy (txt + prevsize, addr + 8, csize); txt[txtsize] = 0; } @@ -243,7 +243,7 @@ static void to_iff_ilbm (HBITMAP hbmp) return; bmpw = (w * bpp / 8 + 3) & ~3; size = bmpw * h; - bmp.bmBits = xmalloc (size); + bmp.bmBits = xmalloc (uae_u8, size); if (!GetBitmapBits (hbmp, size, bmp.bmBits)) { xfree (bmp.bmBits); return; @@ -280,7 +280,7 @@ static void to_iff_ilbm (HBITMAP hbmp) bodysize = (((w + 15) & ~15) / 8) * h * iffbpp; iffsize = sizeof (iffilbm) + (8 + 256 * 3 + 1) + (4 + 4) + bodysize; - iff = xcalloc (iffsize, 1); + iff = xcalloc (uae_u8, iffsize); memcpy (iff, iffilbm, sizeof iffilbm); p = iff + 5 * 4; // BMHD @@ -404,7 +404,7 @@ static uae_u8 *iff_decomp (uae_u8 *addr, int w, int h, int planes) uae_u8 *dst; w2 = (w + 15) & ~15; - dst = xmalloc (w2 * h * planes); + dst = xmalloc (uae_u8, w2 * h * planes); for (y = 0; y < h * planes; y++) { uae_u8 *p = dst + w2 * y; uae_u8 *end = p + w2; @@ -519,7 +519,7 @@ static void from_iff_ilbm (uaecptr ilbm, uae_u32 len) bmsize = sizeof (BITMAPINFO); if (bmpdepth <= 8) bmsize += (1 << planes) * sizeof (RGBQUAD); - bmih = xcalloc (bmsize, 1); + bmih = (BITMAPINFO*)xcalloc (uae_u8, bmsize); bmih->bmiHeader.biSize = sizeof (bmih->bmiHeader); bmih->bmiHeader.biWidth = w; bmih->bmiHeader.biHeight = -h; @@ -545,7 +545,7 @@ static void from_iff_ilbm (uaecptr ilbm, uae_u32 len) } } } - bmptr = xcalloc (bmpw * h, 1); + bmptr = xcalloc (uae_u8, bmpw * h); if (compr) addr = caddr = iff_decomp (addr, w, h, planes + (masking == 1 ? 1 : 0)); @@ -687,7 +687,7 @@ static void clipboard_read (HWND hwnd) if (text) { hglb = GetClipboardData (CF_UNICODETEXT); if (hglb != NULL) { - TCHAR *lptstr = GlobalLock (hglb); + TCHAR *lptstr = (TCHAR*)GlobalLock (hglb); if (lptstr != NULL) { //write_log (L"clipboard: CF_UNICODETEXT '%s'\n", lptstr); to_iff_text (lptstr); @@ -695,7 +695,7 @@ static void clipboard_read (HWND hwnd) } } } else if (bmp) { - HBITMAP hbmp = GetClipboardData (CF_BITMAP); + HBITMAP hbmp = (HBITMAP)GetClipboardData (CF_BITMAP); if (hbmp != NULL) { //write_log (L"clipboard: CF_BITMAP\n"); to_iff_ilbm (hbmp); @@ -757,7 +757,7 @@ static int clipboard_put_text_real (const TCHAR *txt) EmptyClipboard (); hglb = GlobalAlloc (GMEM_MOVEABLE, (_tcslen (txt) + 1) * sizeof (TCHAR)); if (hglb) { - TCHAR *lptstr = GlobalLock (hglb); + TCHAR *lptstr = (TCHAR*)GlobalLock (hglb); _tcscpy (lptstr, txt); GlobalUnlock (hglb); SetClipboardData (CF_UNICODETEXT, hglb); @@ -858,7 +858,7 @@ void clipboard_active (HWND hwnd, int active) } if (!clipactive && clipboard_delayed_data) { if (clipboard_delayed_size < 0) { - clipboard_put_text_real (clipboard_delayed_data); + clipboard_put_text_real ((TCHAR*)clipboard_delayed_data); xfree (clipboard_delayed_data); } else { clipboard_put_bmp_real ((HBITMAP)clipboard_delayed_data); diff --git a/od-win32/clirun.c b/od-win32/clirun.cpp similarity index 100% rename from od-win32/clirun.c rename to od-win32/clirun.cpp diff --git a/od-win32/cloanto/RetroPlatformGuestIPC.c b/od-win32/cloanto/RetroPlatformGuestIPC.cpp similarity index 100% rename from od-win32/cloanto/RetroPlatformGuestIPC.c rename to od-win32/cloanto/RetroPlatformGuestIPC.cpp diff --git a/od-win32/debug_win32.c b/od-win32/debug_win32.cpp similarity index 99% rename from od-win32/debug_win32.c rename to od-win32/debug_win32.cpp index c9a97b8d..26431382 100644 --- a/od-win32/debug_win32.c +++ b/od-win32/debug_win32.cpp @@ -101,7 +101,7 @@ static void OutputCurrHistNode(HWND hWnd) if (currhist->command) { txtlen = GetWindowTextLength(hWnd); - buf = xmalloc((txtlen + 1) * sizeof (TCHAR)); + buf = xmalloc(TCHAR, txtlen + 1); GetWindowText(hWnd, buf, txtlen + 1); if (_tcscmp(buf, currhist->command)) { SetWindowText(hWnd, currhist->command); @@ -165,7 +165,7 @@ static void AddToHistory(const TCHAR *command) else if (histcount == MAXINPUTHIST) DeleteFromHistory(1); tmp = lasthist; - lasthist = malloc(sizeof(struct histnode)); + lasthist = xmalloc(struct histnode, 1); if (histcount == 0) firsthist = lasthist; lasthist->command = my_strdup(command); @@ -241,7 +241,7 @@ void WriteOutput(const TCHAR *out, int len) pos = p - tmp + 1; if (pos > (MAX_LINEWIDTH + 1)) pos = MAX_LINEWIDTH + 1; - buf = xcalloc(pos + 2, sizeof (TCHAR)); + buf = xcalloc(TCHAR, pos + 2); _tcsncpy(buf, tmp, pos - 1); _tcscat(buf, linebreak); } else if (_tcslen(tmp) == 0) { @@ -251,7 +251,7 @@ void WriteOutput(const TCHAR *out, int len) index = SendMessage(hOutput, EM_LINEINDEX, count - 1, 0); txtlen = SendMessage(hOutput, EM_LINELENGTH, index, 0); if (_tcslen(tmp) + txtlen > MAX_LINEWIDTH) { - buf = xcalloc(MAX_LINEWIDTH + 3 - txtlen, sizeof (TCHAR)); + buf = xcalloc(TCHAR, MAX_LINEWIDTH + 3 - txtlen); _tcsncpy(buf, tmp, MAX_LINEWIDTH - txtlen); _tcscat(buf, linebreak); } @@ -830,7 +830,7 @@ static LRESULT CALLBACK MemInputProc (HWND hWnd, UINT message, WPARAM wParam, LP return TRUE; hdata = GetClipboardData(CF_UNICODETEXT); if (hdata) { - lptstr = GlobalLock(hdata); + lptstr = (LPWSTR)GlobalLock(hdata); if (lptstr) { if (_tcsspn(lptstr, allowed) != _tcslen(lptstr)) ok = 0; @@ -956,7 +956,7 @@ static void CopyListboxText(HWND hwnd, BOOL all) hdata = GlobalAlloc(GMEM_MOVEABLE, size * sizeof (TCHAR)); if (hdata) { int pos = 0; - lptstr = GlobalLock(hdata); + lptstr = (LPWSTR)GlobalLock(hdata); lptstr[size - 1] = '\0'; for (i = start; i < end; i++) { int len = SendMessage(hwnd, LB_GETTEXTLEN, i, 0); @@ -1149,7 +1149,7 @@ static LRESULT CALLBACK ListboxEditProc(HWND hWnd, UINT message, WPARAM wParam, return TRUE; hdata = GetClipboardData(CF_UNICODETEXT); if (hdata) { - lptstr = GlobalLock(hdata); + lptstr = (LPWSTR)GlobalLock(hdata); if (lptstr) { if (_tcsspn(lptstr, allowed) != _tcslen(lptstr)) ok = 0; @@ -1374,9 +1374,9 @@ static LRESULT CALLBACK ListboxProc(HWND hWnd, UINT message, WPARAM wParam, LPAR count = SendMessage(hWnd, LB_GETCOUNT, 0, 0); compdc = CreateCompatibleDC(hdc); compbmp = CreateCompatibleBitmap(hdc, width, height); - oldbmp = SelectObject(compdc, compbmp); + oldbmp = (HBITMAP)SelectObject(compdc, compbmp); font = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0); - oldfont = SelectObject(compdc, font); + oldfont = (HFONT)SelectObject(compdc, font); id = GetDlgCtrlID(hWnd); dis.CtlType = ODT_LISTBOX; dis.CtlID = id; @@ -1708,7 +1708,7 @@ static void SelectListboxLine(HWND hwnd, int x, int y) dbgpage[currpage].selection = index; } -static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hwnd; static BOOL sizing = FALSE; @@ -1716,7 +1716,7 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP case WM_INITDIALOG: { int newpos = 0; - LONG x, y, w, h; + int x, y, w, h; RECT rw; HFONT hfont; LOGFONT lf; diff --git a/od-win32/dinput.c b/od-win32/dinput.cpp similarity index 97% rename from od-win32/dinput.c rename to od-win32/dinput.cpp index 913106fc..269b7bb1 100644 --- a/od-win32/dinput.c +++ b/od-win32/dinput.cpp @@ -125,7 +125,7 @@ int dinput_winmousemode (void) return 0; } -static isrealbutton (struct didata *did, int num) +static int isrealbutton (struct didata *did, int num) { if (num >= did->buttons) return 0; @@ -186,7 +186,7 @@ typedef UINT (CALLBACK* GETRAWINPUTDATA) (HRAWINPUT, UINT, LPVOID, PUINT, UINT); static GETRAWINPUTDATA pGetRawInputData; typedef UINT (CALLBACK* GETRAWINPUTDEVICELIST) - (PRAWINPUTDEVICEKUST, PUINT, UINT); + (PRAWINPUTDEVICELIST, PUINT, UINT); static GETRAWINPUTDEVICELIST pGetRawInputDeviceList; typedef UINT (CALLBACK* GETRAWINPUTDEVICEINFO) (HANDLE, UINT, LPVOID, PUINT); @@ -498,7 +498,7 @@ int close_tablet (void *ctx) { #ifndef _WIN64 if (ctx != NULL) - WTClose (ctx); + WTClose ((HCTX)ctx); ctx = NULL; if (!tablet) return 0; @@ -516,7 +516,7 @@ int is_tablet (void) static int initialize_tablet (void) { #ifndef _WIN64 - HANDLE h; + HMODULE h; TCHAR name[MAX_DPATH]; struct tagAXIS ori[3]; int tilt = 0; @@ -736,7 +736,8 @@ static TCHAR *rawkeyboardlabels[256] = static int initialize_rawinput (void) { RAWINPUTDEVICELIST *ridl = 0; - int num = 500, gotnum, i, bufsize, vtmp; + UINT num = 500, vtmp; + int gotnum, i, bufsize; int rnum_mouse, rnum_kb, rnum_raw; TCHAR *buf = NULL; int rmouse = 0, rkb = 0; @@ -762,7 +763,7 @@ static int initialize_rawinput (void) goto error; bufsize = 10000 * sizeof (TCHAR); - buf = xmalloc (bufsize); + buf = xmalloc (TCHAR, bufsize / sizeof (TCHAR)); register_rawinput (); if (pGetRawInputDeviceList (NULL, &num, sizeof (RAWINPUTDEVICELIST)) != 0) { @@ -772,7 +773,7 @@ static int initialize_rawinput (void) write_log (L"RAWINPUT: found %d devices\n", num); if (num <= 0) goto error2; - ridl = xcalloc (sizeof (RAWINPUTDEVICELIST), num); + ridl = xcalloc (RAWINPUTDEVICELIST, num); gotnum = pGetRawInputDeviceList (ridl, &num, sizeof (RAWINPUTDEVICELIST)); if (gotnum <= 0) { write_log (L"RAWINPUT didn't find any devices\n"); @@ -1268,7 +1269,7 @@ static int makesort_mouse (const GUID *g, int *dwofs) static BOOL CALLBACK EnumObjectsCallback (const DIDEVICEOBJECTINSTANCE* pdidoi, VOID *pContext) { - struct didata *did = pContext; + struct didata *did = (struct didata*)pContext; int i; TCHAR tmp[100]; @@ -1402,10 +1403,10 @@ static BOOL di_enumcallback2 (LPCDIDEVICEINSTANCE lpddi, int joy) cleardid (did); if (lpddi->tszInstanceName) { len = _tcslen (lpddi->tszInstanceName) + 5 + 1; - did->name = malloc (len * sizeof (TCHAR)); + did->name = xmalloc (TCHAR, len); _tcscpy (did->name, lpddi->tszInstanceName); } else { - did->name = malloc (100); + did->name = xmalloc (TCHAR, 100); _stprintf (did->name, L"[no name]"); } trimws (did->name); @@ -1431,11 +1432,11 @@ static BOOL di_enumcallback2 (LPCDIDEVICEINSTANCE lpddi, int joy) return DIENUM_CONTINUE; } -static BOOL CALLBACK di_enumcallback (LPCDIDEVICEINSTANCE lpddi, LPVOID *dd) +static BOOL CALLBACK di_enumcallback (LPCDIDEVICEINSTANCE lpddi, LPVOID dd) { return di_enumcallback2 (lpddi, 0); } -static BOOL CALLBACK di_enumcallbackj (LPCDIDEVICEINSTANCE lpddi, LPVOID *dd) +static BOOL CALLBACK di_enumcallbackj (LPCDIDEVICEINSTANCE lpddi, LPVOID dd) { return di_enumcallback2 (lpddi, 1); } @@ -1466,7 +1467,7 @@ static int di_do_init (void) di_dev_free (&di_mouse[i]); di_dev_free (&di_keyboard[i]); } - hr = DirectInput8Create (hInst, DIRECTINPUT_VERSION, &IID_IDirectInput8, (LPVOID *)&g_lpdi, NULL); + hr = DirectInput8Create (hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID *)&g_lpdi, NULL); if (FAILED(hr)) { write_log (L"DirectInput8Create failed, %s\n", DXError (hr)); gui_message (L"Failed to initialize DirectInput!"); @@ -1474,16 +1475,16 @@ static int di_do_init (void) } if (dinput_enum_all) { write_log (L"DirectInput enumeration..\n"); - IDirectInput8_EnumDevices (g_lpdi, DI8DEVCLASS_ALL, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); + g_lpdi->EnumDevices (DI8DEVCLASS_ALL, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); } else { if (rawkeyboard <= 0) { write_log (L"DirectInput enumeration.. Keyboards..\n"); - IDirectInput8_EnumDevices (g_lpdi, DI8DEVCLASS_KEYBOARD, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); + g_lpdi->EnumDevices (DI8DEVCLASS_KEYBOARD, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); } write_log (L"DirectInput enumeration.. Pointing devices..\n"); - IDirectInput8_EnumDevices (g_lpdi, DI8DEVCLASS_POINTER, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); + g_lpdi->EnumDevices (DI8DEVCLASS_POINTER, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); write_log (L"DirectInput enumeration.. Game controllers..\n"); - IDirectInput8_EnumDevices (g_lpdi, DI8DEVCLASS_GAMECTRL, di_enumcallbackj, 0, DIEDFL_ATTACHEDONLY); + g_lpdi->EnumDevices (DI8DEVCLASS_GAMECTRL, di_enumcallbackj, 0, DIEDFL_ATTACHEDONLY); } write_log (L"RawInput enumeration..\n"); initialize_rawinput (); @@ -1593,7 +1594,7 @@ static int init_mouse (void) for (i = 0; i < num_mouse; i++) { did = &di_mouse[i]; if (did->connection == DIDC_DX) { - hr = IDirectInput8_CreateDevice (g_lpdi, &did->iguid, &lpdi, NULL); + hr = g_lpdi->CreateDevice (did->iguid, &lpdi, NULL); if (SUCCEEDED (hr)) { hr = IDirectInputDevice8_SetDataFormat (lpdi, &c_dfDIMouse2); IDirectInputDevice8_EnumObjects (lpdi, EnumObjectsCallback, (void*)did, DIDFT_ALL); @@ -1948,9 +1949,9 @@ static int init_kb (void) for (i = 0; i < num_keyboard; i++) { struct didata *did = &di_keyboard[i]; if (did->connection == DIDC_DX) { - hr = IDirectInput8_CreateDevice (g_lpdi, &did->iguid, &lpdi, NULL); + hr = g_lpdi->CreateDevice (did->iguid, &lpdi, NULL); if (SUCCEEDED (hr)) { - hr = IDirectInputDevice8_SetDataFormat (lpdi, &c_dfDIKeyboard); + hr = lpdi->SetDataFormat (&c_dfDIKeyboard); if (FAILED (hr)) write_log (L"keyboard setdataformat failed, %s\n", DXError (hr)); memset (&dipdw, 0, sizeof (dipdw)); @@ -1959,10 +1960,10 @@ static int init_kb (void) dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = DI_KBBUFFER; - hr = IDirectInputDevice8_SetProperty (lpdi, DIPROP_BUFFERSIZE, &dipdw.diph); + hr = lpdi->SetProperty (DIPROP_BUFFERSIZE, &dipdw.diph); if (FAILED (hr)) write_log (L"keyboard setpropertry failed, %s\n", DXError (hr)); - IDirectInputDevice8_EnumObjects (lpdi, EnumObjectsCallback, did, DIDFT_ALL); + lpdi->EnumObjects (EnumObjectsCallback, did, DIDFT_ALL); sortobjects (did, did->axismappings, did->axissort, did->axisname, did->axistype, did->axles); sortobjects (did, did->buttonmappings, did->buttonsort, did->buttonname, 0, did->buttons); did->lpdi = lpdi; @@ -2431,12 +2432,12 @@ static int init_joystick (void) for (i = 0; i < num_joystick; i++) { did = &di_joystick[i]; if (did->connection == DIDC_DX) { - hr = IDirectInput8_CreateDevice (g_lpdi, &did->iguid, &lpdi, NULL); + hr = g_lpdi->CreateDevice (did->iguid, &lpdi, NULL); if (SUCCEEDED (hr)) { - hr = IDirectInputDevice8_SetDataFormat (lpdi, &c_dfDIJoystick); + hr = lpdi->SetDataFormat (&c_dfDIJoystick); if (SUCCEEDED (hr)) { did->lpdi = lpdi; - IDirectInputDevice8_EnumObjects (lpdi, EnumObjectsCallback, (void*)did, DIDFT_ALL); + lpdi->EnumObjects (EnumObjectsCallback, (void*)did, DIDFT_ALL); fixbuttons (did); fixthings (did); sortobjects (did, did->axismappings, did->axissort, did->axisname, did->axistype, did->axles); diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index ae9bbc73..03348e8f 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -6,8 +6,6 @@ #if defined (D3D) && defined (GFXFILTER) -extern "C" -{ #include "options.h" #include "xwin.h" #include "custom.h" @@ -20,7 +18,6 @@ extern "C" #include "hq2x_d3d.h" #include "zfile.h" extern int D3DEX, d3ddebug; -} #include #include @@ -857,7 +854,7 @@ static int createmasktexture (TCHAR *filename) } } size = zfile_size (zf); - buf = (uae_u8*)xmalloc (size); + buf = xmalloc (uae_u8, size); zfile_fread (buf, size, 1, zf); zfile_fclose (zf); hr = D3DXCreateTextureFromFileInMemoryEx (d3ddev, buf, size, diff --git a/od-win32/diskutil.c b/od-win32/diskutil.cpp similarity index 100% rename from od-win32/diskutil.c rename to od-win32/diskutil.cpp diff --git a/od-win32/driveclick_win32.c b/od-win32/driveclick_win32.cpp similarity index 100% rename from od-win32/driveclick_win32.c rename to od-win32/driveclick_win32.cpp diff --git a/od-win32/dxwrap.c b/od-win32/dxwrap.cpp similarity index 99% rename from od-win32/dxwrap.c rename to od-win32/dxwrap.cpp index 28eb2334..7f5089ea 100644 --- a/od-win32/dxwrap.c +++ b/od-win32/dxwrap.cpp @@ -658,9 +658,9 @@ void DirectDraw_SurfaceUnlock (void) unlocksurface (getlocksurface ()); } -void *DirectDraw_GetSurfacePointer (void) +uae_u8 *DirectDraw_GetSurfacePointer (void) { - return dxdata.locksurface.lpSurface; + return (uae_u8*)dxdata.locksurface.lpSurface; } DWORD DirectDraw_GetSurfacePitch (void) { @@ -687,9 +687,9 @@ DWORD DirectDraw_GetPixelFormatBitMask (DirectDraw_Mask_e mask) } return result; } -DWORD DirectDraw_GetPixelFormat (void) +RGBFTYPE DirectDraw_GetPixelFormat (void) { - return DirectDraw_GetSurfacePixelFormat (&dxdata.native); + return (RGBFTYPE)DirectDraw_GetSurfacePixelFormat (&dxdata.native); } DWORD DirectDraw_GetBytesPerPixel (void) { @@ -1173,7 +1173,7 @@ int DirectDraw_Start (GUID *guid) goto oops; } #else - ddrval = DirectDrawCreateEx (guid, &dxdata.maindd, &IID_IDirectDraw7, NULL); + ddrval = DirectDrawCreateEx (guid, (void**)&dxdata.maindd, IID_IDirectDraw7, NULL); if (FAILED (ddrval)) { write_log (L"DirectDrawCreateEx() failed, %s\n", DXError (ddrval)); if (guid != NULL) diff --git a/od-win32/dxwrap.h b/od-win32/dxwrap.h index e49257f9..2b196e3f 100644 --- a/od-win32/dxwrap.h +++ b/od-win32/dxwrap.h @@ -112,11 +112,11 @@ DWORD DirectDraw_CurrentHeight (void); DWORD DirectDraw_GetCurrentDepth (void); int DirectDraw_SurfaceLock (void); void DirectDraw_SurfaceUnlock (void); -void *DirectDraw_GetSurfacePointer (void); +uae_u8 *DirectDraw_GetSurfacePointer (void); DWORD DirectDraw_GetSurfacePitch (void); int DirectDraw_IsLocked (void); DWORD DirectDraw_GetPixelFormatBitMask (DirectDraw_Mask_e mask); -DWORD DirectDraw_GetPixelFormat (void); +RGBFTYPE DirectDraw_GetPixelFormat (void); DWORD DirectDraw_GetBytesPerPixel (void); HRESULT DirectDraw_GetDC(HDC *hdc); HRESULT DirectDraw_ReleaseDC(HDC hdc); diff --git a/od-win32/fdrawcmd.c b/od-win32/fdrawcmd.cpp similarity index 100% rename from od-win32/fdrawcmd.c rename to od-win32/fdrawcmd.cpp diff --git a/od-win32/fsdb_mywin32.c b/od-win32/fsdb_mywin32.cpp similarity index 91% rename from od-win32/fsdb_mywin32.c rename to od-win32/fsdb_mywin32.cpp index 384d9ee9..30662da8 100644 --- a/od-win32/fsdb_mywin32.c +++ b/od-win32/fsdb_mywin32.cpp @@ -32,7 +32,7 @@ static int recycle (const TCHAR *name) } else { SHFILEOPSTRUCT fos; /* name must be terminated by \0\0 */ - TCHAR *p = xcalloc ((_tcslen (name) + 2) * sizeof (TCHAR), 1); + TCHAR *p = xcalloc (TCHAR, _tcslen (name) + 2); int v; _tcscpy (p, name); @@ -63,7 +63,7 @@ static int recycle (const TCHAR *name) int my_rmdir (const TCHAR *name) { - void *od; + struct my_opendir_s *od; int cnt; TCHAR tname[MAX_DPATH]; @@ -100,20 +100,20 @@ int my_rename (const TCHAR *oldname, const TCHAR *newname) return MoveFile (oldname, newname) == 0 ? -1 : 0; } -struct my_opendirs { - HANDLE *h; +struct my_opendir_s { + HANDLE h; WIN32_FIND_DATA fd; int first; }; -void *my_opendir (const TCHAR *name) +struct my_opendir_s *my_opendir (const TCHAR *name) { - struct my_opendirs *mod; + struct my_opendir_s *mod; TCHAR tmp[MAX_DPATH]; _tcscpy (tmp, name); _tcscat (tmp, L"\\*.*"); - mod = xmalloc (sizeof (struct my_opendirs)); + mod = xmalloc (struct my_opendir_s, 1); if (!mod) return NULL; mod->h = FindFirstFile(tmp, &mod->fd); @@ -125,17 +125,15 @@ void *my_opendir (const TCHAR *name) return mod; } -void my_closedir (void *d) +void my_closedir (struct my_opendir_s *mod) { - struct my_opendirs *mod = d; - if (d) + if (mod) FindClose (mod->h); xfree (mod); } -int my_readdir (void *d, TCHAR *name) +int my_readdir (struct my_opendir_s *mod, TCHAR *name) { - struct my_opendirs *mod = d; if (mod->first) { _tcscpy (name, mod->fd.cFileName); mod->first = 0; @@ -147,20 +145,18 @@ int my_readdir (void *d, TCHAR *name) return 1; } -struct my_opens { - HANDLE *h; +struct my_openfile_s { + HANDLE h; }; -void my_close (void *d) +void my_close (struct my_openfile_s *mos) { - struct my_opens *mos = d; CloseHandle (mos->h); xfree (mos); } -uae_s64 int my_lseek (void *d, uae_s64 int offset, int whence) +uae_s64 int my_lseek (struct my_openfile_s *mos, uae_s64 int offset, int whence) { - struct my_opens *mos = d; LARGE_INTEGER li; li.QuadPart = offset; @@ -171,17 +167,15 @@ uae_s64 int my_lseek (void *d, uae_s64 int offset, int whence) return li.QuadPart; } -unsigned int my_read (void *d, void *b, unsigned int size) +unsigned int my_read (struct my_openfile_s *mos, void *b, unsigned int size) { - struct my_opens *mos = d; DWORD read = 0; ReadFile (mos->h, b, size, &read, NULL); return read; } -unsigned int my_write (void *d, void *b, unsigned int size) +unsigned int my_write (struct my_openfile_s *mos, void *b, unsigned int size) { - struct my_opens *mos = d; DWORD written = 0; WriteFile (mos->h, b, size, &written, NULL); return written; @@ -217,9 +211,9 @@ int my_existsdir (const TCHAR *name) return 0; } -void *my_open (const TCHAR *name, int flags) +struct my_openfile_s *my_open (const TCHAR *name, int flags) { - struct my_opens *mos; + struct my_openfile_s *mos; HANDLE h; DWORD DesiredAccess = GENERIC_READ; DWORD ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; @@ -227,7 +221,7 @@ void *my_open (const TCHAR *name, int flags) DWORD FlagsAndAttributes = FILE_ATTRIBUTE_NORMAL; DWORD attr; - mos = xmalloc (sizeof (struct my_opens)); + mos = xmalloc (struct my_openfile_s, 1); if (!mos) return NULL; attr = GetFileAttributesSafe (name); diff --git a/od-win32/fsdb_win32.c b/od-win32/fsdb_win32.cpp similarity index 94% rename from od-win32/fsdb_win32.c rename to od-win32/fsdb_win32.cpp index 4f4bfccd..73d79a10 100644 --- a/od-win32/fsdb_win32.c +++ b/od-win32/fsdb_win32.cpp @@ -60,7 +60,7 @@ static TCHAR *make_uaefsdbpath (const TCHAR *dir, const TCHAR *name) if (name) len += 1 + _tcslen (name); len += 1 + _tcslen (FSDB_FILE); - p = xmalloc (len * sizeof (TCHAR)); + p = xmalloc (TCHAR, len); if (!p) return NULL; if (name) @@ -91,9 +91,9 @@ static int read_uaefsdb (const TCHAR *dir, const TCHAR *name, uae_u8 *fsdb) if (fsdb_debug) { TCHAR *an, *nn, *co; write_log (L"->ok\n"); - an = aucp (fsdb + 5, currprefs.win32_fscodepage); - nn = aucp (fsdb + 262, currprefs.win32_fscodepage); - co = aucp (fsdb + 519, currprefs.win32_fscodepage); + an = aucp ((char*)fsdb + 5, currprefs.win32_fscodepage); + nn = aucp ((char*)fsdb + 262, currprefs.win32_fscodepage); + co = aucp ((char*)fsdb + 519, currprefs.win32_fscodepage); write_log (L"v=%02x flags=%08x an='%s' nn='%s' c='%s'\n", fsdb[0], ((uae_u32*)(fsdb+1))[0], an, nn, co); xfree (co); @@ -148,9 +148,9 @@ static int write_uaefsdb (const TCHAR *dir, uae_u8 *fsdb) NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fsdb_debug) { TCHAR *an, *nn, *co; - an = aucp (fsdb + 5, currprefs.win32_fscodepage); - nn = aucp (fsdb + 262, currprefs.win32_fscodepage); - co = aucp (fsdb + 519, currprefs.win32_fscodepage); + an = aucp ((char*)fsdb + 5, currprefs.win32_fscodepage); + nn = aucp ((char*)fsdb + 262, currprefs.win32_fscodepage); + co = aucp ((char*)fsdb + 519, currprefs.win32_fscodepage); write_log (L"write_uaefsdb '%s' = %x\n", p, h); write_log (L"v=%02x flags=%08x an='%s' nn='%s' c='%s'\n", fsdb[0], ((uae_u32*)(fsdb+1))[0], an, nn, co); @@ -206,16 +206,16 @@ static void create_uaefsdb (a_inode *aino, uae_u8 *buf, int winmode) buf[0] = 1; do_put_mem_long ((uae_u32 *)(buf + 1), aino->amigaos_mode); s = uacp (aino->aname, currprefs.win32_fscodepage); - strncpy (buf + 5, s, 256); + strncpy ((char*)buf + 5, s, 256); buf[5 + 256] = '\0'; xfree (s); nn = nname_begin (aino->nname); s = uacp (nn, currprefs.win32_fscodepage); - strncpy (buf + 5 + 257, s, 256); + strncpy ((char*)buf + 5 + 257, s, 256); buf[5 + 257 + 256] = '\0'; xfree (s); s = uacp (aino->comment ? aino->comment : L"", currprefs.win32_fscodepage); - strncpy (buf + 5 + 2 * 257, s, 80); + strncpy ((char*)buf + 5 + 2 * 257, s, 80); buf[5 + 2 * 257 + 80] = '\0'; xfree (s); do_put_mem_long ((uae_u32 *)(buf + 5 + 2 * 257 + 81), winmode); @@ -227,7 +227,7 @@ static void create_uaefsdb (a_inode *aino, uae_u8 *buf, int winmode) static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, int *winmode) { uae_u32 mode; - a_inode *aino = xcalloc (sizeof (a_inode), 1); + a_inode *aino = xcalloc (a_inode, 1); uae_u8 *buf2; TCHAR *s; @@ -237,19 +237,19 @@ static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, int *winmode) if (buf2[0]) { aino->aname = my_strdup ((TCHAR*)buf2); } else { - aino->aname = aucp (buf, currprefs.win32_fscodepage); + aino->aname = aucp ((char*)buf, currprefs.win32_fscodepage); } buf += 257; buf2 += 257 * 2; if (buf2[0]) { aino->nname = build_nname (base->nname, (TCHAR*)buf2); } else { - s = aucp (buf, currprefs.win32_fscodepage); + s = aucp ((char*)buf, currprefs.win32_fscodepage); aino->nname = build_nname (base->nname, s); xfree (s); } buf += 257; - aino->comment = *buf != '\0' ? my_strdup_ansi (buf) : 0; + aino->comment = *buf != '\0' ? my_strdup_ansi ((char*)buf) : 0; buf += 81; aino->amigaos_mode = mode; *winmode = do_get_mem_long ((uae_u32 *)buf); @@ -365,7 +365,7 @@ int fsdb_fill_file_attrs (a_inode *base, a_inode *aino) xfree (aino->comment); aino->comment = NULL; if (fsdb[5 + 2 * 257]) - aino->comment = my_strdup_ansi (fsdb + 5 + 2 * 257); + aino->comment = my_strdup_ansi ((char*)fsdb + 5 + 2 * 257); xfree (aino_from_buf (base, fsdb, &winmode)); if (winmode == mode) /* no Windows-side editing? */ return 1; @@ -552,7 +552,7 @@ static a_inode *custom_fsdb_lookup_aino (a_inode *base, const TCHAR *aname, int if (h != INVALID_HANDLE_VALUE) { do { if (read_uaefsdb (base->nname, fd.cFileName, fsdb)) { - TCHAR *s = au (fsdb + offset); + TCHAR *s = au ((char*)fsdb + offset); if (same_aname (s, aname)) { int winmode; FindClose (h); diff --git a/od-win32/genblitter_msvc/genblitter_msvc.vcproj b/od-win32/genblitter_msvc/genblitter_msvc.vcproj index e179c9d1..2c379292 100644 --- a/od-win32/genblitter_msvc/genblitter_msvc.vcproj +++ b/od-win32/genblitter_msvc/genblitter_msvc.vcproj @@ -384,11 +384,11 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > diff --git a/od-win32/genblitter_msvc/genblitter_msvc.vcxproj b/od-win32/genblitter_msvc/genblitter_msvc.vcxproj index f59602ce..7e8cb44b 100644 --- a/od-win32/genblitter_msvc/genblitter_msvc.vcxproj +++ b/od-win32/genblitter_msvc/genblitter_msvc.vcxproj @@ -101,10 +101,9 @@ deleting blitter files del ..\..\blit.h -del ..\..\blitfunc.c +del ..\..\blitfunc.cpp del ..\..\blitfunc.h -del ..\..\blittable.c - +del ..\..\blittable.cpp /MACHINE:I386 %(AdditionalOptions) @@ -119,9 +118,10 @@ del ..\..\blittable.c generating blitter files genblitter.exe i >..\..\blit.h -genblitter.exe f >..\..\blitfunc.c +genblitter.exe f >..\..\blitfunc.cpp genblitter.exe h >..\..\blitfunc.h -genblitter.exe t >..\..\blittable.c +genblitter.exe t >..\..\blittable.cpp +del genblitter.exe @@ -280,8 +280,8 @@ genblitter.exe t >..\..\blittable.c - - + + diff --git a/od-win32/genblitter_msvc/genblitter_msvc.vcxproj.filters b/od-win32/genblitter_msvc/genblitter_msvc.vcxproj.filters index e8d1afe0..a91d1e80 100644 --- a/od-win32/genblitter_msvc/genblitter_msvc.vcxproj.filters +++ b/od-win32/genblitter_msvc/genblitter_msvc.vcxproj.filters @@ -7,10 +7,10 @@ - + Source Files - + Source Files diff --git a/od-win32/gencomp_msvc/gencomp_msvc.vcproj b/od-win32/gencomp_msvc/gencomp_msvc.vcproj index b305bb52..0f37a2e8 100644 --- a/od-win32/gencomp_msvc/gencomp_msvc.vcproj +++ b/od-win32/gencomp_msvc/gencomp_msvc.vcproj @@ -378,19 +378,19 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > diff --git a/od-win32/gencomp_msvc/gencomp_msvc.vcxproj b/od-win32/gencomp_msvc/gencomp_msvc.vcxproj index 40f2b3fd..88ee243f 100644 --- a/od-win32/gencomp_msvc/gencomp_msvc.vcxproj +++ b/od-win32/gencomp_msvc/gencomp_msvc.vcxproj @@ -113,6 +113,8 @@ generating gencomp files cd ..\.. od-win32\gencomp_msvc\gencomp.exe +del od-win32\gencomp_msvc\gencomp.exe + @@ -243,10 +245,10 @@ od-win32\gencomp_msvc\gencomp.exe - - - - + + + + diff --git a/od-win32/gencomp_msvc/gencomp_msvc.vcxproj.filters b/od-win32/gencomp_msvc/gencomp_msvc.vcxproj.filters index dc77363c..21011b42 100644 --- a/od-win32/gencomp_msvc/gencomp_msvc.vcxproj.filters +++ b/od-win32/gencomp_msvc/gencomp_msvc.vcxproj.filters @@ -7,16 +7,16 @@ - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/od-win32/gencpu_msvc/gencpu.exe.manifest b/od-win32/gencpu_msvc/gencpu.exe.manifest deleted file mode 100644 index 11bb704c..00000000 --- a/od-win32/gencpu_msvc/gencpu.exe.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/od-win32/gencpu_msvc/gencpu_msvc.vcproj b/od-win32/gencpu_msvc/gencpu_msvc.vcproj index 9e3660ef..44b91ccf 100644 --- a/od-win32/gencpu_msvc/gencpu_msvc.vcproj +++ b/od-win32/gencpu_msvc/gencpu_msvc.vcproj @@ -386,23 +386,23 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > diff --git a/od-win32/gencpu_msvc/gencpu_msvc.vcxproj b/od-win32/gencpu_msvc/gencpu_msvc.vcxproj index 4cddf611..5f5ac7bb 100644 --- a/od-win32/gencpu_msvc/gencpu_msvc.vcxproj +++ b/od-win32/gencpu_msvc/gencpu_msvc.vcxproj @@ -151,8 +151,9 @@ od-win32\gencpu_msvc\gencpu.exe deleting gencpu files del ..\..\cputbl.h -del ..\..\cpustbl.c -del ..\..\cpuemu.c +del ..\..\cpustbl.cpp +del ..\..\cpuemu.cpp + @@ -169,6 +170,7 @@ del ..\..\cpuemu.c generating gencpu files cd ..\.. od-win32\gencpu_msvc\gencpu.exe +del od-win32\gencpu_msvc\gencpu.exe @@ -267,11 +269,11 @@ od-win32\gencpu_msvc\gencpu.exe - - - - - + + + + + diff --git a/od-win32/gencpu_msvc/gencpu_msvc.vcxproj.filters b/od-win32/gencpu_msvc/gencpu_msvc.vcxproj.filters index c707f41d..6365f2c8 100644 --- a/od-win32/gencpu_msvc/gencpu_msvc.vcxproj.filters +++ b/od-win32/gencpu_msvc/gencpu_msvc.vcxproj.filters @@ -7,19 +7,19 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcproj b/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcproj index 6e4d076f..aa2dc089 100644 --- a/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcproj +++ b/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcproj @@ -131,8 +131,8 @@ /> @@ -260,7 +260,7 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > diff --git a/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcxproj b/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcxproj index 3ed1075c..b07c1ec6 100644 --- a/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcxproj +++ b/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcxproj @@ -95,8 +95,9 @@ ProgramDatabase - deleteing linetoscr.c - del ..\..\linetoscr.c + deleteing linetoscr.cpp + del ..\..\linetoscr.cpp + genlinetoscr.exe @@ -111,7 +112,9 @@ generating linetoscr.c - genlinetoscr.exe >..\..\linetoscr.c + genlinetoscr.exe >..\..\linetoscr.cpp +del genlinetoscr.exe + @@ -148,7 +151,7 @@ - + diff --git a/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcxproj.filters b/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcxproj.filters index 7f375d74..469cf00b 100644 --- a/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcxproj.filters +++ b/od-win32/genlinetoscr_msvc/genlinetoscr_msvc.vcxproj.filters @@ -7,7 +7,7 @@ - + Source Files diff --git a/od-win32/hardfile_win32.c b/od-win32/hardfile_win32.cpp similarity index 93% rename from od-win32/hardfile_win32.c rename to od-win32/hardfile_win32.cpp index c5f69cb4..29e9dd8f 100644 --- a/od-win32/hardfile_win32.c +++ b/od-win32/hardfile_win32.cpp @@ -31,6 +31,13 @@ static int usefloppydrives = 0; +struct hardfilehandle +{ + int zfile; + struct zfile *zf; + HANDLE h; +}; + struct uae_driveinfo { TCHAR vendor_id[128]; TCHAR product_id[128]; @@ -73,7 +80,7 @@ static int isnomediaerr (DWORD err) return 0; } -static void rdbdump (HANDLE *h, uae_u64 offset, uae_u8 *buf, int blocksize) +static void rdbdump (HANDLE h, uae_u64 offset, uae_u8 *buf, int blocksize) { static int cnt = 1; int i, blocks; @@ -88,7 +95,8 @@ static void rdbdump (HANDLE *h, uae_u64 offset, uae_u8 *buf, int blocksize) if (!f) return; for (i = 0; i <= blocks; i++) { - DWORD outlen, high; + DWORD outlen; + LONG high; high = (DWORD)(offset >> 32); if (SetFilePointer (h, (DWORD)offset, &high, FILE_BEGIN) == INVALID_FILE_SIZE) break; @@ -108,7 +116,7 @@ static int getsignfromhandle (HANDLE h, DWORD *sign, DWORD *pstyle) ok = 0; outsize = sizeof (DRIVE_LAYOUT_INFORMATION_EX) + sizeof (PARTITION_INFORMATION_EX) * 32; - dli = xmalloc (outsize); + dli = (DRIVE_LAYOUT_INFORMATION_EX*)xmalloc (uae_u8, outsize); if (DeviceIoControl (h, IOCTL_DISK_GET_DRIVE_LAYOUT_EX, NULL, 0, dli, outsize, &written, NULL)) { *sign = dli->Mbr.Signature; *pstyle = dli->PartitionStyle; @@ -154,7 +162,7 @@ static int ismounted (HANDLE hd) isntfs = 1; } outsize = sizeof (VOLUME_DISK_EXTENTS) + sizeof (DISK_EXTENT) * 32; - vde = xmalloc (outsize); + vde = (VOLUME_DISK_EXTENTS*)xmalloc (uae_u8, outsize); if (DeviceIoControl (d, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, vde, outsize, &written, NULL)) { int i; for (i = 0; i < vde->NumberOfDiskExtents; i++) { @@ -186,13 +194,14 @@ static int ismounted (HANDLE hd) } #define CA "Commodore\0Amiga\0" -static int safetycheck (HANDLE *h, const TCHAR *name, uae_u64 offset, uae_u8 *buf, int blocksize) +static int safetycheck (HANDLE h, const TCHAR *name, uae_u64 offset, uae_u8 *buf, int blocksize) { int i, j, blocks = 63, empty = 1; - DWORD outlen, high; + DWORD outlen; + LONG high; for (j = 0; j < blocks; j++) { - high = (DWORD)(offset >> 32); + high = (LONG)(offset >> 32); if (SetFilePointer (h, (DWORD)offset, &high, FILE_BEGIN) == INVALID_FILE_SIZE) { write_log (L"hd ignored, SetFilePointer failed, error %d\n", GetLastError ()); return 1; @@ -238,7 +247,7 @@ static int safetycheck (HANDLE *h, const TCHAR *name, uae_u64 offset, uae_u8 *bu int match = 0; if (fkey) { int idx = 0; - DWORD size, size2; + int size, size2; TCHAR tmp2[MAX_DPATH], tmp[MAX_DPATH]; for (;;) { size = sizeof (tmp) / sizeof (TCHAR); @@ -336,7 +345,7 @@ int hdf_open_target (struct hardfiledata *hfd, const TCHAR *pname) hfd->flags = 0; hfd->drive_empty = 0; hdf_close (hfd); - hfd->cache = VirtualAlloc (NULL, CACHE_SIZE, MEM_COMMIT, PAGE_READWRITE); + hfd->cache = (uae_u8*)VirtualAlloc (NULL, CACHE_SIZE, MEM_COMMIT, PAGE_READWRITE); hfd->cache_valid = 0; hfd->virtual_size = 0; hfd->virtual_rdb = NULL; @@ -344,6 +353,8 @@ int hdf_open_target (struct hardfiledata *hfd, const TCHAR *pname) write_log (L"VirtualAlloc(%d) failed, error %d\n", CACHE_SIZE, GetLastError ()); goto end; } + hfd->handle = xcalloc (struct hardfilehandle, 1); + hfd->handle->h = INVALID_HANDLE_VALUE; hfd_log (L"hfd open: '%s'\n", name); if (_tcslen (name) > 4 && !_tcsncmp (name, L"HD_", 3)) { hdf_init_target (); @@ -361,7 +372,7 @@ int hdf_open_target (struct hardfiledata *hfd, const TCHAR *pname) GENERIC_READ | (hfd->readonly ? 0 : GENERIC_WRITE), FILE_SHARE_READ | (hfd->readonly ? 0 : FILE_SHARE_WRITE), NULL, OPEN_EXISTING, flags, NULL); - hfd->handle = h; + hfd->handle->h = h; if (h == INVALID_HANDLE_VALUE) goto end; if (!DeviceIoControl(h, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, &r, NULL)) @@ -373,7 +384,7 @@ int hdf_open_target (struct hardfiledata *hfd, const TCHAR *pname) hfd->physsize = hfd->virtsize = udi->size; hfd->blocksize = udi->bytespersector; if (hfd->offset == 0 && !hfd->drive_empty) { - int sf = safetycheck (hfd->handle, udi->device_path, 0, hfd->cache, hfd->blocksize); + int sf = safetycheck (hfd->handle->h, udi->device_path, 0, hfd->cache, hfd->blocksize); if (sf > 0) goto end; if (sf == 0 && !hfd->readonly && harddrive_dangerous != 0x1234dead) { @@ -385,7 +396,7 @@ int hdf_open_target (struct hardfiledata *hfd, const TCHAR *pname) GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, flags, NULL); - hfd->handle = h; + hfd->handle->h = h; if (h == INVALID_HANDLE_VALUE) goto end; if (!DeviceIoControl(h, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, &r, NULL)) @@ -428,7 +439,7 @@ int hdf_open_target (struct hardfiledata *hfd, const TCHAR *pname) } h = CreateFile (name, GENERIC_READ | (hfd->readonly ? 0 : GENERIC_WRITE), hfd->readonly ? FILE_SHARE_READ : 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); - hfd->handle = h; + hfd->handle->h = h; i = _tcslen (name) - 1; while (i >= 0) { if ((i > 0 && (name[i - 1] == '/' || name[i - 1] == '\\')) || i == 0) { @@ -440,33 +451,35 @@ int hdf_open_target (struct hardfiledata *hfd, const TCHAR *pname) i--; } if (h != INVALID_HANDLE_VALUE) { - DWORD ret, low, high; - high = 0; + DWORD ret, low; + LONG high = 0; + DWORD high2; ret = SetFilePointer (h, 0, &high, FILE_END); if (ret == INVALID_FILE_SIZE && GetLastError () != NO_ERROR) goto end; - low = GetFileSize (h, &high); + low = GetFileSize (h, &high2); if (low == INVALID_FILE_SIZE && GetLastError () != NO_ERROR) goto end; low &= ~(hfd->blocksize - 1); - hfd->physsize = hfd->virtsize = ((uae_u64)high << 32) | low; + hfd->physsize = hfd->virtsize = ((uae_u64)high2 << 32) | low; hfd->handle_valid = HDF_HANDLE_WIN32; if (hfd->physsize < 64 * 1024 * 1024 && zmode) { write_log (L"HDF '%s' re-opened in zfile-mode\n", name); CloseHandle (h); - hfd->handle = h = zfile_fopen(name, hfd->readonly ? L"rb" : L"r+b", ZFD_NORMAL); + hfd->handle->h = INVALID_HANDLE_VALUE; + hfd->handle->zf = zfile_fopen(name, hfd->readonly ? L"rb" : L"r+b", ZFD_NORMAL); + hfd->handle->zfile = 1; if (!h) goto end; - zfile_fseek (h, 0, SEEK_END); - hfd->physsize = hfd->virtsize = zfile_ftell (h); - zfile_fseek (h, 0, SEEK_SET); + zfile_fseek (hfd->handle->zf, 0, SEEK_END); + hfd->physsize = hfd->virtsize = zfile_ftell (hfd->handle->zf); + zfile_fseek (hfd->handle->zf, 0, SEEK_SET); hfd->handle_valid = HDF_HANDLE_ZFILE; } } else { write_log (L"HDF '%s' failed to open. error = %d\n", name, GetLastError ()); } } - hfd->handle = h; if (hfd->handle_valid || hfd->drive_empty) { hfd_log (L"HDF '%s' opened, size=%dK mode=%d empty=%d\n", name, hfd->physsize / 1024, hfd->handle_valid, hfd->drive_empty); @@ -478,19 +491,26 @@ end: return 0; } +static void freehandle (struct hardfilehandle *h) +{ + if (!h) + return; + if (!h->zfile && h->h != INVALID_HANDLE_VALUE) + CloseHandle (h->h); + if (h->zfile && h->zf) + zfile_fclose (h->zf); + h->zf = NULL; + h->h = INVALID_HANDLE_VALUE; + h->zfile = 0; +} + void hdf_close_target (struct hardfiledata *hfd) { - if (hfd->handle_valid) { - if (hfd->handle && hfd->handle != INVALID_HANDLE_VALUE) { - if (hfd->handle_valid == HDF_HANDLE_WIN32) - CloseHandle (hfd->handle); - else if(hfd->handle_valid == HDF_HANDLE_ZFILE) - zfile_fclose (hfd->handle); - } - } + freehandle (hfd->handle); + xfree (hfd->handle); xfree (hfd->emptyname); hfd->emptyname = NULL; - hfd->handle = 0; + hfd->handle = NULL; hfd->handle_valid = 0; if (hfd->cache) VirtualFree (hfd->cache, 0, MEM_RELEASE); @@ -507,21 +527,23 @@ int hdf_dup_target (struct hardfiledata *dhfd, const struct hardfiledata *shfd) { if (!shfd->handle_valid) return 0; + freehandle (dhfd->handle); if (shfd->handle_valid == HDF_HANDLE_WIN32) { HANDLE duphandle; - if (!DuplicateHandle (GetCurrentProcess (), shfd->handle, GetCurrentProcess () , &duphandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) + if (!DuplicateHandle (GetCurrentProcess (), shfd->handle->h, GetCurrentProcess () , &duphandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) return 0; - dhfd->handle = duphandle; + dhfd->handle->h = duphandle; dhfd->handle_valid = HDF_HANDLE_WIN32; } else if (shfd->handle_valid == HDF_HANDLE_ZFILE) { struct zfile *zf; - zf = zfile_dup (shfd->handle); + zf = zfile_dup (shfd->handle->zf); if (!zf) return 0; - dhfd->handle = zf; + dhfd->handle->zf = zf; + dhfd->handle->zfile = 1; dhfd->handle_valid = HDF_HANDLE_ZFILE; } - dhfd->cache = VirtualAlloc (NULL, CACHE_SIZE, MEM_COMMIT, PAGE_READWRITE); + dhfd->cache = (uae_u8*)VirtualAlloc (NULL, CACHE_SIZE, MEM_COMMIT, PAGE_READWRITE); dhfd->cache_valid = 0; if (!dhfd->cache) { hdf_close (dhfd); @@ -532,7 +554,7 @@ int hdf_dup_target (struct hardfiledata *dhfd, const struct hardfiledata *shfd) static int hdf_seek (struct hardfiledata *hfd, uae_u64 offset) { - DWORD high, ret; + DWORD ret; if (hfd->handle_valid == 0) { gui_message (L"hd: hdf handle is not valid. bug."); @@ -549,24 +571,24 @@ static int hdf_seek (struct hardfiledata *hfd, uae_u64 offset) abort (); } if (hfd->handle_valid == HDF_HANDLE_WIN32) { - high = (DWORD)(offset >> 32); - ret = SetFilePointer (hfd->handle, (DWORD)offset, &high, FILE_BEGIN); + LONG high = (LONG)(offset >> 32); + ret = SetFilePointer (hfd->handle->h, (DWORD)offset, &high, FILE_BEGIN); if (ret == INVALID_FILE_SIZE && GetLastError() != NO_ERROR) return -1; } else if (hfd->handle_valid == HDF_HANDLE_ZFILE) { - zfile_fseek (hfd->handle, (long)offset, SEEK_SET); + zfile_fseek (hfd->handle->zf, (long)offset, SEEK_SET); } return 0; } static void poscheck (struct hardfiledata *hfd, int len) { - DWORD high, ret, err; + DWORD ret, err; uae_u64 pos; if (hfd->handle_valid == HDF_HANDLE_WIN32) { - high = 0; - ret = SetFilePointer (hfd->handle, 0, &high, FILE_CURRENT); + LONG high = 0; + ret = SetFilePointer (hfd->handle->h, 0, &high, FILE_CURRENT); err = GetLastError (); if (ret == INVALID_FILE_SIZE && err != NO_ERROR) { gui_message (L"hd: poscheck failed. seek failure, error %d", err); @@ -574,7 +596,7 @@ static void poscheck (struct hardfiledata *hfd, int len) } pos = ((uae_u64)high) << 32 | ret; } else if (hfd->handle_valid == HDF_HANDLE_ZFILE) { - pos = zfile_ftell (hfd->handle); + pos = zfile_ftell (hfd->handle->zf); } if (len < 0) { gui_message (L"hd: poscheck failed, negative length! (%d)", len); @@ -727,9 +749,9 @@ static int hdf_read_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, i hdf_seek (hfd, hfd->cache_offset); poscheck (hfd, CACHE_SIZE); if (hfd->handle_valid == HDF_HANDLE_WIN32) - ReadFile (hfd->handle, hfd->cache, CACHE_SIZE, &outlen, NULL); + ReadFile (hfd->handle->h, hfd->cache, CACHE_SIZE, &outlen, NULL); else if (hfd->handle_valid == HDF_HANDLE_ZFILE) - outlen = zfile_fread (hfd->cache, 1, CACHE_SIZE, hfd->handle); + outlen = zfile_fread (hfd->cache, 1, CACHE_SIZE, hfd->handle->zf); hfd->cache_valid = 0; if (outlen != CACHE_SIZE) return 0; @@ -747,7 +769,7 @@ static int hdf_read_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, i int hdf_read_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) { int got = 0; - uae_u8 *p = buffer; + uae_u8 *p = (uae_u8*)buffer; if (hfd->drive_empty) return 0; @@ -760,16 +782,17 @@ int hdf_read_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int } offset -= hfd->virtual_size; while (len > 0) { - int ret, maxlen; + int maxlen; + DWORD ret; if (hfd->physsize < CACHE_SIZE) { hfd->cache_valid = 0; hdf_seek (hfd, offset); poscheck (hfd, len); if (hfd->handle_valid == HDF_HANDLE_WIN32) { - ReadFile (hfd->handle, hfd->cache, len, &ret, NULL); + ReadFile (hfd->handle->h, hfd->cache, len, &ret, NULL); memcpy (buffer, hfd->cache, ret); } else if (hfd->handle_valid == HDF_HANDLE_ZFILE) { - ret = zfile_fread (buffer, 1, len, hfd->handle); + ret = zfile_fread (buffer, 1, len, hfd->handle->zf); } maxlen = len; } else { @@ -799,15 +822,15 @@ static int hdf_write_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, poscheck (hfd, len); memcpy (hfd->cache, buffer, len); if (hfd->handle_valid == HDF_HANDLE_WIN32) - WriteFile (hfd->handle, hfd->cache, len, &outlen, NULL); + WriteFile (hfd->handle->h, hfd->cache, len, &outlen, NULL); else if (hfd->handle_valid == HDF_HANDLE_ZFILE) - outlen = zfile_fwrite (hfd->cache, 1, len, hfd->handle); + outlen = zfile_fwrite (hfd->cache, 1, len, hfd->handle->zf); return outlen; } int hdf_write_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) { int got = 0; - uae_u8 *p = buffer; + uae_u8 *p = (uae_u8*)buffer; if (hfd->drive_empty) return 0; @@ -816,7 +839,7 @@ int hdf_write_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, in offset -= hfd->virtual_size; while (len > 0) { int maxlen = len > CACHE_SIZE ? CACHE_SIZE : len; - int ret = hdf_write_2(hfd, p, offset, maxlen); + int ret = hdf_write_2 (hfd, p, offset, maxlen); if (ret < 0) return ret; got += ret; @@ -836,16 +859,16 @@ int hdf_resize_target (struct hardfiledata *hfd, uae_u64 newsize) if (newsize >= 0x80000000) { highword = (DWORD)(newsize >> 32); - ret = SetFilePointer (hfd->handle, (DWORD)newsize, &highword, FILE_BEGIN); + ret = SetFilePointer (hfd->handle->h, (DWORD)newsize, &highword, FILE_BEGIN); } else { - ret = SetFilePointer (hfd->handle, (DWORD)newsize, NULL, FILE_BEGIN); + ret = SetFilePointer (hfd->handle->h, (DWORD)newsize, NULL, FILE_BEGIN); } err = GetLastError (); if (ret == INVALID_SET_FILE_POINTER && err != NO_ERROR) { write_log (L"hdf_resize_target: SetFilePointer() %d\n", err); return 0; } - if (SetEndOfFile (hfd->handle)) { + if (SetEndOfFile (hfd->handle->h)) { hfd->physsize = newsize; return 1; } @@ -1261,7 +1284,7 @@ static BOOL GetDeviceProperty(HDEVINFO IntDevInfo, DWORD Index, DWORD *index2, u // interfaceDetailDataSize = reqSize; - interfaceDetailData = malloc (interfaceDetailDataSize); + interfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)xmalloc (uae_u8, interfaceDetailDataSize); if (interfaceDetailData == NULL) { write_log (L"Unable to allocate memory to get the interface detail data.\n"); ret = 0; @@ -1314,7 +1337,7 @@ static int hdf_init2 (int force) done = 1; num_drives = 0; #ifdef WINDDK - buffer = VirtualAlloc (NULL, 65536, MEM_COMMIT, PAGE_READWRITE); + buffer = (uae_u8*)VirtualAlloc (NULL, 65536, MEM_COMMIT, PAGE_READWRITE); if (buffer) { errormode = SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); memset (uae_drives, 0, sizeof (uae_drives)); @@ -1452,7 +1475,7 @@ TCHAR *hdf_getnameharddrive (int index, int flags, int *sectorsize, int *dangero static int hmc (struct hardfiledata *hfd) { - uae_u8 *buf = xmalloc (hfd->blocksize); + uae_u8 *buf = xmalloc (uae_u8, hfd->blocksize); DWORD ret, got, err, status; int first = 1; @@ -1461,8 +1484,8 @@ static int hmc (struct hardfiledata *hfd) write_log (L"testing if %s has media inserted\n", hfd->emptyname); status = 0; errormode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); - SetFilePointer (hfd->handle, 0, NULL, FILE_BEGIN); - ret = ReadFile (hfd->handle, buf, hfd->blocksize, &got, NULL); + SetFilePointer (hfd->handle->h, 0, NULL, FILE_BEGIN); + ret = ReadFile (hfd->handle->h, buf, hfd->blocksize, &got, NULL); err = GetLastError (); SetErrorMode(errormode); if (ret) { diff --git a/od-win32/hq2x_d3d.c b/od-win32/hq2x_d3d.cpp similarity index 100% rename from od-win32/hq2x_d3d.c rename to od-win32/hq2x_d3d.cpp diff --git a/od-win32/ioport.c b/od-win32/ioport.cpp similarity index 99% rename from od-win32/ioport.c rename to od-win32/ioport.cpp index 6dc1cd05..322fa1d3 100644 --- a/od-win32/ioport.c +++ b/od-win32/ioport.cpp @@ -8,7 +8,9 @@ #define io_log #define para_log write_log +#ifndef __cplusplus typedef int bool; +#endif #include #include "win32.h" diff --git a/od-win32/ipctester.c b/od-win32/ipctester.cpp similarity index 100% rename from od-win32/ipctester.c rename to od-win32/ipctester.cpp diff --git a/od-win32/keyboard_win32.c b/od-win32/keyboard_win32.cpp similarity index 100% rename from od-win32/keyboard_win32.c rename to od-win32/keyboard_win32.cpp diff --git a/od-win32/lcd.c b/od-win32/lcd.cpp similarity index 96% rename from od-win32/lcd.c rename to od-win32/lcd.cpp index b4e20016..d4646bff 100644 --- a/od-win32/lcd.c +++ b/od-win32/lcd.cpp @@ -66,10 +66,10 @@ static int lcd_init (void) lcd_close (); return 0; } - lbh = xcalloc (1, sizeof (lgLcdBitmapHeader) + desc.Width * (desc.Height + 20)); + lbh = (lgLcdBitmapHeader*)xcalloc (uae_u8, sizeof (lgLcdBitmapHeader) + desc.Width * (desc.Height + 20)); lbh->Format = LGLCD_BMP_FORMAT_160x43x1; bitmap = (uae_u8*)lbh + sizeof (lgLcdBitmapHeader); - origbitmap = xcalloc (1, desc.Width * desc.Height); + origbitmap = xcalloc (uae_u8, desc.Width * desc.Height); memset (&octx, 0, sizeof (octx)); octx.connection = cctx.connection; octx.index = 0; diff --git a/od-win32/machdep/support.c b/od-win32/machdep/support.cpp similarity index 100% rename from od-win32/machdep/support.c rename to od-win32/machdep/support.cpp diff --git a/od-win32/midi.c b/od-win32/midi.cpp similarity index 98% rename from od-win32/midi.c rename to od-win32/midi.cpp index 9001261c..7afc9510 100644 --- a/od-win32/midi.c +++ b/od-win32/midi.cpp @@ -72,7 +72,7 @@ static uae_u8 *outbuffer[MIDI_BUFFERS] = { 0, 0 }; static long outbufferlength[MIDI_BUFFERS] = { 0, 0 }; static int outbufferselect = 0; static int out_allocated = 0; -static volatile exitin = 0; +static volatile int exitin = 0; static CRITICAL_SECTION cs_proc; /* * FUNCTION: getmidiouterr @@ -120,7 +120,7 @@ static int MidiOut_Alloc(void) if(!out_allocated) { for(i = 0; i < MIDI_BUFFERS; i++) { if(!outbuffer[i]) { - outbuffer[i] = (char*)xmalloc(BUFFLEN); + outbuffer[i] = xmalloc(uae_u8, BUFFLEN); if(outbuffer[i]) { outbufferlength[i] = BUFFLEN; out_allocated++; @@ -252,7 +252,7 @@ static int MidiIn_Alloc(void) if(!in_allocated) { for(i = 0; i < MIDI_INBUFFERS; i++) { if(!inbuffer[i]) { - inbuffer[i] = (char*)xmalloc(INBUFFLEN); + inbuffer[i] = xmalloc(uae_u8, INBUFFLEN); if(inbuffer[i]) { inbufferlength[i] = INBUFFLEN; in_allocated++; @@ -364,7 +364,7 @@ int Midi_Parse(midi_direction_e direction, BYTE *dataptr) bufferindex = BUFFLEN - 1; out_status.status = MIDI_SYSX; // Flush this buffer using midiOutLongMsg - MidiOut_PrepareHeader(&midiout[outbufferselect], bufferpoint, bufferindex); + MidiOut_PrepareHeader(&midiout[outbufferselect], (LPSTR)bufferpoint, bufferindex); midiOutLongMsg(outHandle, &midiout[outbufferselect], sizeof(MIDIHDR)); outbufferselect = !outbufferselect; bufferpoint = outbuffer[outbufferselect]; @@ -634,7 +634,7 @@ int Midi_Open(void) midi_in_ready = FALSE; } else { for (i = 0;i < MIDI_INBUFFERS; i++) { - midiin[i].lpData = inbuffer[i]; + midiin[i].lpData = (LPSTR)inbuffer[i]; midiin[i].dwBufferLength = INBUFFLEN - 1; midiin[i].dwBytesRecorded = INBUFFLEN - 1; midiin[i].dwUser = 0; diff --git a/od-win32/midiin.c b/od-win32/midiin.cpp similarity index 100% rename from od-win32/midiin.c rename to od-win32/midiin.cpp diff --git a/od-win32/mman.c b/od-win32/mman.c deleted file mode 100644 index db667367..00000000 --- a/od-win32/mman.c +++ /dev/null @@ -1,689 +0,0 @@ -// Implement mprotect() for Win32 -// Copyright (C) 2000, Brian King -// GNU Public License - -#include - -#include "sysconfig.h" -#include "sysdeps.h" -#include "sys/mman.h" -#include "memory.h" -#include "options.h" -#include "autoconf.h" -#include "win32.h" - -#if defined(NATMEM_OFFSET) - -#define BARRIER 32 -#define MAXZ3MEM 0x7F000000 -#define MAXZ3MEM64 0xF0000000 - -static struct shmid_ds shmids[MAX_SHMID]; -static int memwatchok = 0; -uae_u8 *natmem_offset, *natmem_offset_end; -static uae_u8 *p96mem_offset; -static int p96mem_size; -static SYSTEM_INFO si; -int maxmem; - -static void *virtualallocwithlock (LPVOID addr, SIZE_T size, DWORD allocationtype, DWORD protect) -{ - void *p = VirtualAlloc (addr, size, allocationtype, protect); - return p; -} -static void virtualfreewithlock (LPVOID addr, SIZE_T size, DWORD freetype) -{ - VirtualFree(addr, size, freetype); -} - -void cache_free (void *cache) -{ - virtualfreewithlock (cache, 0, MEM_RELEASE); -} - -void *cache_alloc (int size) -{ - return virtualallocwithlock (NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); -} - -#if 0 -static void setworkingset(void) -{ - typedef BOOL (CALLBACK* SETPROCESSWORKINGSETSIZE)(HANDLE,SIZE_T,SIZE_T); - SETPROCESSWORKINGSETSIZE pSetProcessWorkingSetSize; - pSetProcessWorkingSetSize = (SETPROCESSWORKINGSETSIZE)GetProcAddress(GetModuleHandle("kernal32.dll", "GetProcessWorkingSetSize"); - if (!pSetProcessWorkingSetSize) - return; - pSetProcessWorkingSetSize(GetCurrentProcess (), - ); -#endif - - static uae_u32 lowmem (void) - { - uae_u32 change = 0; - if (currprefs.z3fastmem_size + currprefs.z3fastmem2_size >= 8 * 1024 * 1024) { - if (currprefs.z3fastmem2_size) { - if (currprefs.z3fastmem2_size <= 128 * 1024 * 1024) { - change = currprefs.z3fastmem2_size; - currprefs.z3fastmem2_size = 0; - } else { - change = currprefs.z3fastmem2_size / 2; - currprefs.z3fastmem2_size >>= 1; - changed_prefs.z3fastmem2_size = currprefs.z3fastmem2_size; - } - } else { - change = currprefs.z3fastmem_size - currprefs.z3fastmem_size / 4; - currprefs.z3fastmem2_size = changed_prefs.z3fastmem2_size = currprefs.z3fastmem_size / 4; - currprefs.z3fastmem_size >>= 1; - changed_prefs.z3fastmem_size = currprefs.z3fastmem_size; - } - } else if (currprefs.gfxmem_size >= 1 * 1024 * 1024) { - change = currprefs.gfxmem_size - currprefs.gfxmem_size / 2; - currprefs.gfxmem_size >>= 1; - changed_prefs.gfxmem_size = currprefs.gfxmem_size; - } - if (currprefs.z3fastmem2_size < 128 * 1024 * 1024) - currprefs.z3fastmem2_size = changed_prefs.z3fastmem2_size = 0; - return change; - } - - typedef UINT (CALLBACK* GETWRITEWATCH) - (DWORD,PVOID,SIZE_T,PVOID*,PULONG_PTR,PULONG); -#define TEST_SIZE (2 * 4096) - static int testwritewatch (void) - { - GETWRITEWATCH pGetWriteWatch; - void *mem; - void *pages[16]; - ULONG_PTR gwwcnt; - ULONG ps; - int ret = 0; - - ps = si.dwPageSize; - - pGetWriteWatch = (GETWRITEWATCH)GetProcAddress (GetModuleHandle (L"kernel32.dll"), "GetWriteWatch"); - if (pGetWriteWatch == NULL) { - write_log (L"GetWriteWatch(): missing!?\n"); - return 0; - } - mem = VirtualAlloc (NULL, TEST_SIZE, MEM_RESERVE | MEM_WRITE_WATCH, PAGE_EXECUTE_READWRITE); - if (mem == NULL) { - write_log (L"GetWriteWatch(): MEM_WRITE_WATCH not supported!? err=%d\n", GetLastError()); - return 0; - } - if (VirtualAlloc (mem, TEST_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE) == NULL) { - write_log (L"GetWriteWatch(): test memory area MEM_COMMIT failed!? err=%d\n", GetLastError()); - goto end; - } - ResetWriteWatch (mem, TEST_SIZE); - ((uae_u8*)mem)[1] = 0; - gwwcnt = TEST_SIZE / ps; - if (GetWriteWatch (WRITE_WATCH_FLAG_RESET, mem, TEST_SIZE, pages, &gwwcnt, &ps)) { - write_log (L"GetWriteWatch(): failed!? err=%d\n", GetLastError ()); - goto end; - } - if (ps != si.dwPageSize) { - write_log (L"GetWriteWatch(): pagesize %d != %d!?\n", si.dwPageSize, ps); - goto end; - } - if (gwwcnt != 1) { - write_log (L"GetWriteWatch(): modified pages returned %d != 1!?\n", gwwcnt); - goto end; - } - if (pages[0] != mem) { - write_log (L"GetWriteWatch(): modified page was wrong!?\n"); - goto end; - } - write_log (L"GetWriteWatch() test ok\n"); - ret = 1; - memwatchok = 1; -end: - if (mem) { - VirtualFree (mem, TEST_SIZE, MEM_DECOMMIT); - VirtualFree (mem, 0, MEM_RELEASE); - } - return ret; - } - - static uae_u8 *memwatchtable; - - int mman_GetWriteWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize, PVOID *lpAddresses, PULONG_PTR lpdwCount, PULONG lpdwGranularity) - { - int i, j, off; - - if (memwatchok) - return GetWriteWatch (0, lpBaseAddress, dwRegionSize, lpAddresses, lpdwCount, lpdwGranularity); - j = 0; - off = ((uae_u8*)lpBaseAddress - (natmem_offset + p96ram_start)) / si.dwPageSize; - for (i = 0; i < dwRegionSize / si.dwPageSize; i++) { - if (j >= *lpdwCount) - break; - if (memwatchtable[off + i]) - lpAddresses[j++] = (uae_u8*)lpBaseAddress + i * si.dwPageSize; - } - *lpdwCount = j; - *lpdwGranularity = si.dwPageSize; - return 0; - } - void mman_ResetWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize) - { - if (memwatchok) { - if (ResetWriteWatch (lpBaseAddress, dwRegionSize)) - write_log (L"ResetWriteWatch() failed, %d\n", GetLastError ()); - } else { - DWORD op; - memset (memwatchtable, 0, p96mem_size / si.dwPageSize); - if (!VirtualProtect (lpBaseAddress, dwRegionSize, PAGE_READWRITE | PAGE_GUARD, &op)) - write_log (L"VirtualProtect() failed, err=%d\n", GetLastError ()); - } - } - - int mman_guard_exception (LPEXCEPTION_POINTERS p) - { - PEXCEPTION_RECORD record = p->ExceptionRecord; - PCONTEXT context = p->ContextRecord; - ULONG_PTR addr = record->ExceptionInformation[1]; - int rw = record->ExceptionInformation[0]; - ULONG_PTR p96addr = (ULONG_PTR)p96mem_offset; - - if (memwatchok) - return EXCEPTION_CONTINUE_SEARCH; - if (addr < p96addr || addr >= p96addr + p96mem_size) - return EXCEPTION_CONTINUE_EXECUTION; - addr -= p96addr; - addr /= si.dwPageSize; - memwatchtable[addr] = 1; - return EXCEPTION_CONTINUE_EXECUTION; - } - - static uae_u64 size64; - typedef BOOL (CALLBACK* GLOBALMEMORYSTATUSEX)(LPMEMORYSTATUSEX); - - void preinit_shm (void) - { - int i; - uae_u64 total64; - uae_u64 totalphys64; - MEMORYSTATUS memstats; - GLOBALMEMORYSTATUSEX pGlobalMemoryStatusEx; - MEMORYSTATUSEX memstatsex; - uae_u32 max_allowed_mman; - - GetSystemInfo (&si); - max_allowed_mman = 1536; - if (os_64bit) - max_allowed_mman = 2048; - - memstats.dwLength = sizeof(memstats); - GlobalMemoryStatus(&memstats); - totalphys64 = memstats.dwTotalPhys; - total64 = (uae_u64)memstats.dwAvailPageFile + (uae_u64)memstats.dwTotalPhys; - pGlobalMemoryStatusEx = (GLOBALMEMORYSTATUSEX)GetProcAddress (GetModuleHandle (L"kernel32.dll"), "GlobalMemoryStatusEx"); - if (pGlobalMemoryStatusEx) { - memstatsex.dwLength = sizeof (MEMORYSTATUSEX); - if (pGlobalMemoryStatusEx(&memstatsex)) { - totalphys64 = memstatsex.ullTotalPhys; - total64 = memstatsex.ullAvailPageFile + memstatsex.ullTotalPhys; - } - } - size64 = total64; - if (maxmem < 0) - size64 = MAXZ3MEM; - else if (maxmem > 0) - size64 = maxmem * 1024 * 1024; - if (os_64bit) { - if (size64 > MAXZ3MEM64) - size64 = MAXZ3MEM64; - } else { - if (size64 > MAXZ3MEM) - size64 = MAXZ3MEM; - } - if (size64 < 8 * 1024 * 1024) - size64 = 8 * 1024 * 1024; - if (max_allowed_mman * 1024 * 1024 > size64) - max_allowed_mman = size64 / (1024 * 1024); - max_z3fastmem = max_allowed_mman * 1024 * 1024; - if (max_z3fastmem < 512 * 1024 * 1024) - max_z3fastmem = 512 * 1024 * 1024; - - shm_start = 0; - for (i = 0; i < MAX_SHMID; i++) { - shmids[i].attached = 0; - shmids[i].key = -1; - shmids[i].size = 0; - shmids[i].addr = NULL; - shmids[i].name[0] = 0; - } - - write_log (L"Max Z3FastRAM %dM. Total physical RAM %uM\n", max_z3fastmem >> 20, totalphys64 >> 20); - testwritewatch (); - canbang = 1; - } - - static void resetmem (void) - { - int i; - - if (!shm_start) - return; - for (i = 0; i < MAX_SHMID; i++) { - struct shmid_ds *s = &shmids[i]; - int size = s->size; - uae_u8 *shmaddr; - uae_u8 *result; - - if (!s->attached) - continue; - if (!s->natmembase) - continue; - shmaddr = natmem_offset + ((uae_u8*)s->attached - (uae_u8*)s->natmembase); - result = virtualallocwithlock (shmaddr, size, MEM_COMMIT, s->mode); - if (result != shmaddr) - write_log (L"NATMEM: realloc(%p,%d,%d) failed, err=%x\n", shmaddr, size, s->mode, GetLastError ()); - else - write_log (L"NATMEM: rellocated(%p,%d,%s)\n", shmaddr, size, s->name); - } - } - - int init_shm (void) - { - uae_u32 size, totalsize, z3size, natmemsize, rtgbarrier, rtgextra; - int rounds = 0; - -restart: - for (;;) { - int lowround = 0; - LPVOID blah = NULL; - if (rounds > 0) - write_log (L"NATMEM: retrying %d..\n", rounds); - rounds++; - if (natmem_offset) - VirtualFree(natmem_offset, 0, MEM_RELEASE); - natmem_offset = NULL; - natmem_offset_end = NULL; - canbang = 0; - - z3size = 0; - size = 0x1000000; - rtgextra = 0; - rtgbarrier = si.dwPageSize; - if (currprefs.cpu_model >= 68020) - size = 0x10000000; - if (currprefs.z3fastmem_size || currprefs.z3fastmem2_size) { - z3size = currprefs.z3fastmem_size + currprefs.z3fastmem2_size + (currprefs.z3fastmem_start - 0x10000000); - if (currprefs.gfxmem_size) - rtgbarrier = 16 * 1024 * 1024; - } else { - rtgbarrier = 0; - } - totalsize = size + z3size + currprefs.gfxmem_size; - while (totalsize > size64) { - int change = lowmem (); - if (!change) - return 0; - write_log (L"NATMEM: %d, %dM > %dM = %dM\n", ++lowround, totalsize >> 20, size64 >> 20, (totalsize - change) >> 20); - totalsize -= change; - } - if ((rounds > 1 && totalsize < 0x10000000) || rounds > 20) { - write_log (L"NATMEM: No special area could be allocated (3)!\n"); - return 0; - } - natmemsize = size + z3size; - - xfree (memwatchtable); - memwatchtable = 0; - if (currprefs.gfxmem_size) { - if (!memwatchok) { - write_log (L"GetWriteWatch() not supported, using guard pages, RTG performance will be slower.\n"); - memwatchtable = xcalloc (currprefs.gfxmem_size / si.dwPageSize + 1, 1); - } - } - if (currprefs.gfxmem_size) { - rtgextra = si.dwPageSize; - } else { - rtgbarrier = 0; - rtgextra = 0; - } - blah = VirtualAlloc (NULL, natmemsize + rtgbarrier + currprefs.gfxmem_size + rtgextra + 16 * si.dwPageSize, MEM_RESERVE, PAGE_READWRITE); - if (blah) { - natmem_offset = blah; - break; - } - write_log (L"NATMEM: %dM area failed to allocate, err=%d (Z3=%dM,RTG=%dM)\n", - natmemsize >> 20, GetLastError (), (currprefs.z3fastmem_size + currprefs.z3fastmem2_size) >> 20, currprefs.gfxmem_size >> 20); - if (!lowmem ()) { - write_log (L"NATMEM: No special area could be allocated (2)!\n"); - return 0; - } - } - p96mem_size = currprefs.gfxmem_size; - if (p96mem_size) { - VirtualFree (natmem_offset, 0, MEM_RELEASE); - if (!VirtualAlloc (natmem_offset, natmemsize + rtgbarrier, MEM_RESERVE, PAGE_READWRITE)) { - write_log (L"VirtualAlloc() part 2 error %d. RTG disabled.\n", GetLastError ()); - currprefs.gfxmem_size = changed_prefs.gfxmem_size = 0; - rtgbarrier = si.dwPageSize; - rtgextra = 0; - goto restart; - } - p96mem_offset = VirtualAlloc (natmem_offset + natmemsize + rtgbarrier, p96mem_size + rtgextra, - MEM_RESERVE | (memwatchok == 1 ? MEM_WRITE_WATCH : 0), PAGE_READWRITE); - if (!p96mem_offset) { - currprefs.gfxmem_size = changed_prefs.gfxmem_size = 0; - write_log (L"NATMEM: failed to allocate special Picasso96 GFX RAM, err=%d\n", GetLastError ()); - } - } - - if (!natmem_offset) { - write_log (L"NATMEM: No special area could be allocated! (1) err=%d\n", GetLastError ()); - } else { - write_log (L"NATMEM: Our special area: 0x%p-0x%p (%08x %dM)\n", - natmem_offset, (uae_u8*)natmem_offset + natmemsize, - natmemsize, natmemsize >> 20); - if (currprefs.gfxmem_size) - write_log (L"NATMEM: P96 special area: 0x%p-0x%p (%08x %dM)\n", - p96mem_offset, (uae_u8*)p96mem_offset + currprefs.gfxmem_size, - currprefs.gfxmem_size, currprefs.gfxmem_size >> 20); - canbang = 1; - natmem_offset_end = p96mem_offset + currprefs.gfxmem_size; - } - - resetmem (); - - return canbang; - } - - - void mapped_free (uae_u8 *mem) - { - shmpiece *x = shm_start; - - if (mem == filesysory) { - while(x) { - if (mem == x->native_address) { - int shmid = x->id; - shmids[shmid].key = -1; - shmids[shmid].name[0] = '\0'; - shmids[shmid].size = 0; - shmids[shmid].attached = 0; - shmids[shmid].mode = 0; - shmids[shmid].natmembase = 0; - } - x = x->next; - } - return; - } - - while(x) { - if(mem == x->native_address) - shmdt (x->native_address); - x = x->next; - } - x = shm_start; - while(x) { - struct shmid_ds blah; - if (mem == x->native_address) { - if (shmctl (x->id, IPC_STAT, &blah) == 0) - shmctl (x->id, IPC_RMID, &blah); - } - x = x->next; - } - } - - static key_t get_next_shmkey (void) - { - key_t result = -1; - int i; - for (i = 0; i < MAX_SHMID; i++) { - if (shmids[i].key == -1) { - shmids[i].key = i; - result = i; - break; - } - } - return result; - } - - STATIC_INLINE key_t find_shmkey (key_t key) - { - int result = -1; - if(shmids[key].key == key) { - result = key; - } - return result; - } - - int mprotect (void *addr, size_t len, int prot) - { - int result = 0; - return result; - } - - void *shmat (int shmid, void *shmaddr, int shmflg) - { - void *result = (void *)-1; - BOOL got = FALSE; - int p96special = FALSE; - DWORD protect = PAGE_READWRITE; - -#ifdef NATMEM_OFFSET - unsigned int size = shmids[shmid].size; - - if (shmids[shmid].attached) - return shmids[shmid].attached; - - if ((uae_u8*)shmaddr < natmem_offset) { - if(!_tcscmp (shmids[shmid].name, L"chip")) { - shmaddr=natmem_offset; - got = TRUE; - if (currprefs.fastmem_size == 0 || currprefs.chipmem_size < 2 * 1024 * 1024) - size += BARRIER; - } - if(!_tcscmp (shmids[shmid].name, L"kick")) { - shmaddr=natmem_offset + 0xf80000; - got = TRUE; - size += BARRIER; - } - if(!_tcscmp (shmids[shmid].name, L"rom_a8")) { - shmaddr=natmem_offset + 0xa80000; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"rom_e0")) { - shmaddr=natmem_offset + 0xe00000; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"rom_f0")) { - shmaddr=natmem_offset + 0xf00000; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"rtarea")) { - shmaddr=natmem_offset + rtarea_base; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"fast")) { - shmaddr=natmem_offset + 0x200000; - got = TRUE; - size += BARRIER; - } - if(!_tcscmp (shmids[shmid].name, L"ramsey_low")) { - shmaddr=natmem_offset + a3000lmem_start; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"ramsey_high")) { - shmaddr=natmem_offset + a3000hmem_start; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"z3")) { - shmaddr=natmem_offset + currprefs.z3fastmem_start; - if (!currprefs.z3fastmem2_size) - size += BARRIER; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"z3_2")) { - shmaddr=natmem_offset + currprefs.z3fastmem_start + currprefs.z3fastmem_size; - size += BARRIER; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"gfx")) { - got = TRUE; - p96special = TRUE; - p96ram_start = p96mem_offset - natmem_offset; - shmaddr = natmem_offset + p96ram_start; - size += BARRIER; - if (!memwatchok) - protect |= PAGE_GUARD; - } - if(!_tcscmp (shmids[shmid].name, L"bogo")) { - shmaddr=natmem_offset+0x00C00000; - got = TRUE; - if (currprefs.bogomem_size <= 0x100000) - size += BARRIER; - } - if(!_tcscmp (shmids[shmid].name, L"filesys")) { - static uae_u8 *filesysptr; - if (filesysptr == NULL) - filesysptr = xcalloc (size, 1); - result = filesysptr; - shmids[shmid].attached = result; - return result; - } - if(!_tcscmp (shmids[shmid].name, L"custmem1")) { - shmaddr=natmem_offset + currprefs.custom_memory_addrs[0]; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"custmem2")) { - shmaddr=natmem_offset + currprefs.custom_memory_addrs[1]; - got = TRUE; - } - - if(!_tcscmp (shmids[shmid].name, L"hrtmem")) { - shmaddr=natmem_offset + 0x00a10000; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"arhrtmon")) { - shmaddr=natmem_offset + 0x00800000; - size += BARRIER; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"xpower_e2")) { - shmaddr=natmem_offset + 0x00e20000; - size += BARRIER; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"xpower_f2")) { - shmaddr=natmem_offset + 0x00f20000; - size += BARRIER; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"nordic_f0")) { - shmaddr=natmem_offset + 0x00f00000; - size += BARRIER; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"nordic_f4")) { - shmaddr=natmem_offset + 0x00f40000; - size += BARRIER; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"nordic_f6")) { - shmaddr=natmem_offset + 0x00f60000; - size += BARRIER; - got = TRUE; - } - if(!_tcscmp(shmids[shmid].name, L"superiv_b0")) { - shmaddr=natmem_offset + 0x00b00000; - size += BARRIER; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"superiv_d0")) { - shmaddr=natmem_offset + 0x00d00000; - size += BARRIER; - got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, L"superiv_e0")) { - shmaddr=natmem_offset + 0x00e00000; - size += BARRIER; - got = TRUE; - } - } -#endif - - if (shmids[shmid].key == shmid && shmids[shmid].size) { - shmids[shmid].mode = protect; - shmids[shmid].natmembase = natmem_offset; - if (shmaddr) - virtualfreewithlock (shmaddr, size, MEM_DECOMMIT); - result = virtualallocwithlock (shmaddr, size, MEM_COMMIT, protect); - if (result == NULL) { - result = (void*)-1; - write_log (L"VirtualAlloc %08X - %08X %x (%dk) failed %d\n", - (uae_u8*)shmaddr - natmem_offset, (uae_u8*)shmaddr - natmem_offset + size, - size, size >> 10, GetLastError ()); - } else { - shmids[shmid].attached = result; - write_log (L"VirtualAlloc %08X - %08X %x (%dk) ok%s\n", - (uae_u8*)shmaddr - natmem_offset, (uae_u8*)shmaddr - natmem_offset + size, - size, size >> 10, p96special ? L" P96" : L""); - } - } - return result; - } - - int shmdt (const void *shmaddr) - { - return 0; - } - - int shmget (key_t key, size_t size, int shmflg, const TCHAR *name) - { - int result = -1; - - if((key == IPC_PRIVATE) || ((shmflg & IPC_CREAT) && (find_shmkey (key) == -1))) { - write_log (L"shmget of size %d (%dk) for %s\n", size, size >> 10, name); - if ((result = get_next_shmkey ()) != -1) { - shmids[result].size = size; - _tcscpy (shmids[result].name, name); - } else { - result = -1; - } - } - return result; - } - - int shmctl (int shmid, int cmd, struct shmid_ds *buf) - { - int result = -1; - - if ((find_shmkey (shmid) != -1) && buf) { - switch (cmd) - { - case IPC_STAT: - *buf = shmids[shmid]; - result = 0; - break; - case IPC_RMID: - VirtualFree (shmids[shmid].attached, shmids[shmid].size, MEM_DECOMMIT); - shmids[shmid].key = -1; - shmids[shmid].name[0] = '\0'; - shmids[shmid].size = 0; - shmids[shmid].attached = 0; - shmids[shmid].mode = 0; - result = 0; - break; - } - } - return result; - } - -#endif - - int isinf (double x) - { - const int nClass = _fpclass (x); - int result; - if (nClass == _FPCLASS_NINF || nClass == _FPCLASS_PINF) - result = 1; - else - result = 0; - return result; - } diff --git a/od-win32/mman.cpp b/od-win32/mman.cpp new file mode 100644 index 00000000..625aa21e --- /dev/null +++ b/od-win32/mman.cpp @@ -0,0 +1,690 @@ +// Implement mprotect() for Win32 +// Copyright (C) 2000, Brian King +// GNU Public License + +#include + +#include "sysconfig.h" +#include "sysdeps.h" +#include "sys/mman.h" +#include "memory.h" +#include "options.h" +#include "autoconf.h" +#include "win32.h" + +#if defined(NATMEM_OFFSET) + +#define BARRIER 32 +#define MAXZ3MEM 0x7F000000 +#define MAXZ3MEM64 0xF0000000 + +static struct shmid_ds shmids[MAX_SHMID]; +static int memwatchok = 0; +uae_u8 *natmem_offset, *natmem_offset_end; +static uae_u8 *p96mem_offset; +static int p96mem_size; +static SYSTEM_INFO si; +int maxmem; + +static uae_u8 *virtualallocwithlock (LPVOID addr, SIZE_T size, DWORD allocationtype, DWORD protect) +{ + uae_u8 *p = (uae_u8*)VirtualAlloc (addr, size, allocationtype, protect); + return p; +} +static void virtualfreewithlock (LPVOID addr, SIZE_T size, DWORD freetype) +{ + VirtualFree(addr, size, freetype); +} + +void cache_free (uae_u8 *cache) +{ + virtualfreewithlock (cache, 0, MEM_RELEASE); +} + +uae_u8 *cache_alloc (int size) +{ + return virtualallocwithlock (NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); +} + +#if 0 +static void setworkingset(void) +{ + typedef BOOL (CALLBACK* SETPROCESSWORKINGSETSIZE)(HANDLE,SIZE_T,SIZE_T); + SETPROCESSWORKINGSETSIZE pSetProcessWorkingSetSize; + pSetProcessWorkingSetSize = (SETPROCESSWORKINGSETSIZE)GetProcAddress(GetModuleHandle("kernal32.dll", "GetProcessWorkingSetSize"); + if (!pSetProcessWorkingSetSize) + return; + pSetProcessWorkingSetSize(GetCurrentProcess (), + ); +} +#endif + +static uae_u32 lowmem (void) +{ + uae_u32 change = 0; + if (currprefs.z3fastmem_size + currprefs.z3fastmem2_size >= 8 * 1024 * 1024) { + if (currprefs.z3fastmem2_size) { + if (currprefs.z3fastmem2_size <= 128 * 1024 * 1024) { + change = currprefs.z3fastmem2_size; + currprefs.z3fastmem2_size = 0; + } else { + change = currprefs.z3fastmem2_size / 2; + currprefs.z3fastmem2_size >>= 1; + changed_prefs.z3fastmem2_size = currprefs.z3fastmem2_size; + } + } else { + change = currprefs.z3fastmem_size - currprefs.z3fastmem_size / 4; + currprefs.z3fastmem2_size = changed_prefs.z3fastmem2_size = currprefs.z3fastmem_size / 4; + currprefs.z3fastmem_size >>= 1; + changed_prefs.z3fastmem_size = currprefs.z3fastmem_size; + } + } else if (currprefs.gfxmem_size >= 1 * 1024 * 1024) { + change = currprefs.gfxmem_size - currprefs.gfxmem_size / 2; + currprefs.gfxmem_size >>= 1; + changed_prefs.gfxmem_size = currprefs.gfxmem_size; + } + if (currprefs.z3fastmem2_size < 128 * 1024 * 1024) + currprefs.z3fastmem2_size = changed_prefs.z3fastmem2_size = 0; + return change; +} + +typedef UINT (CALLBACK* GETWRITEWATCH) + (DWORD,PVOID,SIZE_T,PVOID*,PULONG_PTR,PULONG); +#define TEST_SIZE (2 * 4096) +static int testwritewatch (void) +{ + GETWRITEWATCH pGetWriteWatch; + void *mem; + void *pages[16]; + ULONG_PTR gwwcnt; + ULONG ps; + int ret = 0; + + ps = si.dwPageSize; + + pGetWriteWatch = (GETWRITEWATCH)GetProcAddress (GetModuleHandle (L"kernel32.dll"), "GetWriteWatch"); + if (pGetWriteWatch == NULL) { + write_log (L"GetWriteWatch(): missing!?\n"); + return 0; + } + mem = VirtualAlloc (NULL, TEST_SIZE, MEM_RESERVE | MEM_WRITE_WATCH, PAGE_EXECUTE_READWRITE); + if (mem == NULL) { + write_log (L"GetWriteWatch(): MEM_WRITE_WATCH not supported!? err=%d\n", GetLastError()); + return 0; + } + if (VirtualAlloc (mem, TEST_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE) == NULL) { + write_log (L"GetWriteWatch(): test memory area MEM_COMMIT failed!? err=%d\n", GetLastError()); + goto end; + } + ResetWriteWatch (mem, TEST_SIZE); + ((uae_u8*)mem)[1] = 0; + gwwcnt = TEST_SIZE / ps; + if (GetWriteWatch (WRITE_WATCH_FLAG_RESET, mem, TEST_SIZE, pages, &gwwcnt, &ps)) { + write_log (L"GetWriteWatch(): failed!? err=%d\n", GetLastError ()); + goto end; + } + if (ps != si.dwPageSize) { + write_log (L"GetWriteWatch(): pagesize %d != %d!?\n", si.dwPageSize, ps); + goto end; + } + if (gwwcnt != 1) { + write_log (L"GetWriteWatch(): modified pages returned %d != 1!?\n", gwwcnt); + goto end; + } + if (pages[0] != mem) { + write_log (L"GetWriteWatch(): modified page was wrong!?\n"); + goto end; + } + write_log (L"GetWriteWatch() test ok\n"); + ret = 1; + memwatchok = 1; +end: + if (mem) { + VirtualFree (mem, TEST_SIZE, MEM_DECOMMIT); + VirtualFree (mem, 0, MEM_RELEASE); + } + return ret; +} + +static uae_u8 *memwatchtable; + +int mman_GetWriteWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize, PVOID *lpAddresses, PULONG_PTR lpdwCount, PULONG lpdwGranularity) +{ + int i, j, off; + + if (memwatchok) + return GetWriteWatch (0, lpBaseAddress, dwRegionSize, lpAddresses, lpdwCount, lpdwGranularity); + j = 0; + off = ((uae_u8*)lpBaseAddress - (natmem_offset + p96ram_start)) / si.dwPageSize; + for (i = 0; i < dwRegionSize / si.dwPageSize; i++) { + if (j >= *lpdwCount) + break; + if (memwatchtable[off + i]) + lpAddresses[j++] = (uae_u8*)lpBaseAddress + i * si.dwPageSize; + } + *lpdwCount = j; + *lpdwGranularity = si.dwPageSize; + return 0; +} +void mman_ResetWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize) +{ + if (memwatchok) { + if (ResetWriteWatch (lpBaseAddress, dwRegionSize)) + write_log (L"ResetWriteWatch() failed, %d\n", GetLastError ()); + } else { + DWORD op; + memset (memwatchtable, 0, p96mem_size / si.dwPageSize); + if (!VirtualProtect (lpBaseAddress, dwRegionSize, PAGE_READWRITE | PAGE_GUARD, &op)) + write_log (L"VirtualProtect() failed, err=%d\n", GetLastError ()); + } +} + +int mman_guard_exception (LPEXCEPTION_POINTERS p) +{ + PEXCEPTION_RECORD record = p->ExceptionRecord; + PCONTEXT context = p->ContextRecord; + ULONG_PTR addr = record->ExceptionInformation[1]; + int rw = record->ExceptionInformation[0]; + ULONG_PTR p96addr = (ULONG_PTR)p96mem_offset; + + if (memwatchok) + return EXCEPTION_CONTINUE_SEARCH; + if (addr < p96addr || addr >= p96addr + p96mem_size) + return EXCEPTION_CONTINUE_EXECUTION; + addr -= p96addr; + addr /= si.dwPageSize; + memwatchtable[addr] = 1; + return EXCEPTION_CONTINUE_EXECUTION; +} + +static uae_u64 size64; +typedef BOOL (CALLBACK* GLOBALMEMORYSTATUSEX)(LPMEMORYSTATUSEX); + +void preinit_shm (void) +{ + int i; + uae_u64 total64; + uae_u64 totalphys64; + MEMORYSTATUS memstats; + GLOBALMEMORYSTATUSEX pGlobalMemoryStatusEx; + MEMORYSTATUSEX memstatsex; + uae_u32 max_allowed_mman; + + GetSystemInfo (&si); + max_allowed_mman = 1536; + if (os_64bit) + max_allowed_mman = 2048; + + memstats.dwLength = sizeof(memstats); + GlobalMemoryStatus(&memstats); + totalphys64 = memstats.dwTotalPhys; + total64 = (uae_u64)memstats.dwAvailPageFile + (uae_u64)memstats.dwTotalPhys; + pGlobalMemoryStatusEx = (GLOBALMEMORYSTATUSEX)GetProcAddress (GetModuleHandle (L"kernel32.dll"), "GlobalMemoryStatusEx"); + if (pGlobalMemoryStatusEx) { + memstatsex.dwLength = sizeof (MEMORYSTATUSEX); + if (pGlobalMemoryStatusEx(&memstatsex)) { + totalphys64 = memstatsex.ullTotalPhys; + total64 = memstatsex.ullAvailPageFile + memstatsex.ullTotalPhys; + } + } + size64 = total64; + if (maxmem < 0) + size64 = MAXZ3MEM; + else if (maxmem > 0) + size64 = maxmem * 1024 * 1024; + if (os_64bit) { + if (size64 > MAXZ3MEM64) + size64 = MAXZ3MEM64; + } else { + if (size64 > MAXZ3MEM) + size64 = MAXZ3MEM; + } + if (size64 < 8 * 1024 * 1024) + size64 = 8 * 1024 * 1024; + if (max_allowed_mman * 1024 * 1024 > size64) + max_allowed_mman = size64 / (1024 * 1024); + max_z3fastmem = max_allowed_mman * 1024 * 1024; + if (max_z3fastmem < 512 * 1024 * 1024) + max_z3fastmem = 512 * 1024 * 1024; + + shm_start = 0; + for (i = 0; i < MAX_SHMID; i++) { + shmids[i].attached = 0; + shmids[i].key = -1; + shmids[i].size = 0; + shmids[i].addr = NULL; + shmids[i].name[0] = 0; + } + + write_log (L"Max Z3FastRAM %dM. Total physical RAM %uM\n", max_z3fastmem >> 20, totalphys64 >> 20); + testwritewatch (); + canbang = 1; +} + +static void resetmem (void) +{ + int i; + + if (!shm_start) + return; + for (i = 0; i < MAX_SHMID; i++) { + struct shmid_ds *s = &shmids[i]; + int size = s->size; + uae_u8 *shmaddr; + uae_u8 *result; + + if (!s->attached) + continue; + if (!s->natmembase) + continue; + shmaddr = natmem_offset + ((uae_u8*)s->attached - (uae_u8*)s->natmembase); + result = virtualallocwithlock (shmaddr, size, MEM_COMMIT, s->mode); + if (result != shmaddr) + write_log (L"NATMEM: realloc(%p,%d,%d) failed, err=%x\n", shmaddr, size, s->mode, GetLastError ()); + else + write_log (L"NATMEM: rellocated(%p,%d,%s)\n", shmaddr, size, s->name); + } +} + +int init_shm (void) +{ + uae_u32 size, totalsize, z3size, natmemsize, rtgbarrier, rtgextra; + int rounds = 0; + +restart: + for (;;) { + int lowround = 0; + uae_u8 *blah = NULL; + if (rounds > 0) + write_log (L"NATMEM: retrying %d..\n", rounds); + rounds++; + if (natmem_offset) + VirtualFree(natmem_offset, 0, MEM_RELEASE); + natmem_offset = NULL; + natmem_offset_end = NULL; + canbang = 0; + + z3size = 0; + size = 0x1000000; + rtgextra = 0; + rtgbarrier = si.dwPageSize; + if (currprefs.cpu_model >= 68020) + size = 0x10000000; + if (currprefs.z3fastmem_size || currprefs.z3fastmem2_size) { + z3size = currprefs.z3fastmem_size + currprefs.z3fastmem2_size + (currprefs.z3fastmem_start - 0x10000000); + if (currprefs.gfxmem_size) + rtgbarrier = 16 * 1024 * 1024; + } else { + rtgbarrier = 0; + } + totalsize = size + z3size + currprefs.gfxmem_size; + while (totalsize > size64) { + int change = lowmem (); + if (!change) + return 0; + write_log (L"NATMEM: %d, %dM > %dM = %dM\n", ++lowround, totalsize >> 20, size64 >> 20, (totalsize - change) >> 20); + totalsize -= change; + } + if ((rounds > 1 && totalsize < 0x10000000) || rounds > 20) { + write_log (L"NATMEM: No special area could be allocated (3)!\n"); + return 0; + } + natmemsize = size + z3size; + + xfree (memwatchtable); + memwatchtable = 0; + if (currprefs.gfxmem_size) { + if (!memwatchok) { + write_log (L"GetWriteWatch() not supported, using guard pages, RTG performance will be slower.\n"); + memwatchtable = xcalloc (uae_u8, currprefs.gfxmem_size / si.dwPageSize + 1); + } + } + if (currprefs.gfxmem_size) { + rtgextra = si.dwPageSize; + } else { + rtgbarrier = 0; + rtgextra = 0; + } + blah = (uae_u8*)VirtualAlloc (NULL, natmemsize + rtgbarrier + currprefs.gfxmem_size + rtgextra + 16 * si.dwPageSize, MEM_RESERVE, PAGE_READWRITE); + if (blah) { + natmem_offset = blah; + break; + } + write_log (L"NATMEM: %dM area failed to allocate, err=%d (Z3=%dM,RTG=%dM)\n", + natmemsize >> 20, GetLastError (), (currprefs.z3fastmem_size + currprefs.z3fastmem2_size) >> 20, currprefs.gfxmem_size >> 20); + if (!lowmem ()) { + write_log (L"NATMEM: No special area could be allocated (2)!\n"); + return 0; + } + } + p96mem_size = currprefs.gfxmem_size; + if (p96mem_size) { + VirtualFree (natmem_offset, 0, MEM_RELEASE); + if (!VirtualAlloc (natmem_offset, natmemsize + rtgbarrier, MEM_RESERVE, PAGE_READWRITE)) { + write_log (L"VirtualAlloc() part 2 error %d. RTG disabled.\n", GetLastError ()); + currprefs.gfxmem_size = changed_prefs.gfxmem_size = 0; + rtgbarrier = si.dwPageSize; + rtgextra = 0; + goto restart; + } + p96mem_offset = (uae_u8*)VirtualAlloc (natmem_offset + natmemsize + rtgbarrier, p96mem_size + rtgextra, + MEM_RESERVE | (memwatchok == 1 ? MEM_WRITE_WATCH : 0), PAGE_READWRITE); + if (!p96mem_offset) { + currprefs.gfxmem_size = changed_prefs.gfxmem_size = 0; + write_log (L"NATMEM: failed to allocate special Picasso96 GFX RAM, err=%d\n", GetLastError ()); + } + } + + if (!natmem_offset) { + write_log (L"NATMEM: No special area could be allocated! (1) err=%d\n", GetLastError ()); + } else { + write_log (L"NATMEM: Our special area: 0x%p-0x%p (%08x %dM)\n", + natmem_offset, (uae_u8*)natmem_offset + natmemsize, + natmemsize, natmemsize >> 20); + if (currprefs.gfxmem_size) + write_log (L"NATMEM: P96 special area: 0x%p-0x%p (%08x %dM)\n", + p96mem_offset, (uae_u8*)p96mem_offset + currprefs.gfxmem_size, + currprefs.gfxmem_size, currprefs.gfxmem_size >> 20); + canbang = 1; + natmem_offset_end = p96mem_offset + currprefs.gfxmem_size; + } + + resetmem (); + + return canbang; +} + + +void mapped_free (uae_u8 *mem) +{ + shmpiece *x = shm_start; + + if (mem == filesysory) { + while(x) { + if (mem == x->native_address) { + int shmid = x->id; + shmids[shmid].key = -1; + shmids[shmid].name[0] = '\0'; + shmids[shmid].size = 0; + shmids[shmid].attached = 0; + shmids[shmid].mode = 0; + shmids[shmid].natmembase = 0; + } + x = x->next; + } + return; + } + + while(x) { + if(mem == x->native_address) + shmdt (x->native_address); + x = x->next; + } + x = shm_start; + while(x) { + struct shmid_ds blah; + if (mem == x->native_address) { + if (shmctl (x->id, IPC_STAT, &blah) == 0) + shmctl (x->id, IPC_RMID, &blah); + } + x = x->next; + } +} + +static key_t get_next_shmkey (void) +{ + key_t result = -1; + int i; + for (i = 0; i < MAX_SHMID; i++) { + if (shmids[i].key == -1) { + shmids[i].key = i; + result = i; + break; + } + } + return result; +} + +STATIC_INLINE key_t find_shmkey (key_t key) +{ + int result = -1; + if(shmids[key].key == key) { + result = key; + } + return result; +} + +int mprotect (void *addr, size_t len, int prot) +{ + int result = 0; + return result; +} + +void *shmat (int shmid, void *shmaddr, int shmflg) +{ + void *result = (void *)-1; + BOOL got = FALSE; + int p96special = FALSE; + DWORD protect = PAGE_READWRITE; + +#ifdef NATMEM_OFFSET + unsigned int size = shmids[shmid].size; + + if (shmids[shmid].attached) + return shmids[shmid].attached; + + if ((uae_u8*)shmaddr < natmem_offset) { + if(!_tcscmp (shmids[shmid].name, L"chip")) { + shmaddr=natmem_offset; + got = TRUE; + if (currprefs.fastmem_size == 0 || currprefs.chipmem_size < 2 * 1024 * 1024) + size += BARRIER; + } + if(!_tcscmp (shmids[shmid].name, L"kick")) { + shmaddr=natmem_offset + 0xf80000; + got = TRUE; + size += BARRIER; + } + if(!_tcscmp (shmids[shmid].name, L"rom_a8")) { + shmaddr=natmem_offset + 0xa80000; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"rom_e0")) { + shmaddr=natmem_offset + 0xe00000; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"rom_f0")) { + shmaddr=natmem_offset + 0xf00000; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"rtarea")) { + shmaddr=natmem_offset + rtarea_base; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"fast")) { + shmaddr=natmem_offset + 0x200000; + got = TRUE; + size += BARRIER; + } + if(!_tcscmp (shmids[shmid].name, L"ramsey_low")) { + shmaddr=natmem_offset + a3000lmem_start; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"ramsey_high")) { + shmaddr=natmem_offset + a3000hmem_start; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"z3")) { + shmaddr=natmem_offset + currprefs.z3fastmem_start; + if (!currprefs.z3fastmem2_size) + size += BARRIER; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"z3_2")) { + shmaddr=natmem_offset + currprefs.z3fastmem_start + currprefs.z3fastmem_size; + size += BARRIER; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"gfx")) { + got = TRUE; + p96special = TRUE; + p96ram_start = p96mem_offset - natmem_offset; + shmaddr = natmem_offset + p96ram_start; + size += BARRIER; + if (!memwatchok) + protect |= PAGE_GUARD; + } + if(!_tcscmp (shmids[shmid].name, L"bogo")) { + shmaddr=natmem_offset+0x00C00000; + got = TRUE; + if (currprefs.bogomem_size <= 0x100000) + size += BARRIER; + } + if(!_tcscmp (shmids[shmid].name, L"filesys")) { + static uae_u8 *filesysptr; + if (filesysptr == NULL) + filesysptr = xcalloc (uae_u8, size); + result = filesysptr; + shmids[shmid].attached = result; + return result; + } + if(!_tcscmp (shmids[shmid].name, L"custmem1")) { + shmaddr=natmem_offset + currprefs.custom_memory_addrs[0]; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"custmem2")) { + shmaddr=natmem_offset + currprefs.custom_memory_addrs[1]; + got = TRUE; + } + + if(!_tcscmp (shmids[shmid].name, L"hrtmem")) { + shmaddr=natmem_offset + 0x00a10000; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"arhrtmon")) { + shmaddr=natmem_offset + 0x00800000; + size += BARRIER; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"xpower_e2")) { + shmaddr=natmem_offset + 0x00e20000; + size += BARRIER; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"xpower_f2")) { + shmaddr=natmem_offset + 0x00f20000; + size += BARRIER; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"nordic_f0")) { + shmaddr=natmem_offset + 0x00f00000; + size += BARRIER; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"nordic_f4")) { + shmaddr=natmem_offset + 0x00f40000; + size += BARRIER; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"nordic_f6")) { + shmaddr=natmem_offset + 0x00f60000; + size += BARRIER; + got = TRUE; + } + if(!_tcscmp(shmids[shmid].name, L"superiv_b0")) { + shmaddr=natmem_offset + 0x00b00000; + size += BARRIER; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"superiv_d0")) { + shmaddr=natmem_offset + 0x00d00000; + size += BARRIER; + got = TRUE; + } + if(!_tcscmp (shmids[shmid].name, L"superiv_e0")) { + shmaddr=natmem_offset + 0x00e00000; + size += BARRIER; + got = TRUE; + } + } +#endif + + if (shmids[shmid].key == shmid && shmids[shmid].size) { + shmids[shmid].mode = protect; + shmids[shmid].natmembase = natmem_offset; + if (shmaddr) + virtualfreewithlock (shmaddr, size, MEM_DECOMMIT); + result = virtualallocwithlock (shmaddr, size, MEM_COMMIT, protect); + if (result == NULL) { + result = (void*)-1; + write_log (L"VirtualAlloc %08X - %08X %x (%dk) failed %d\n", + (uae_u8*)shmaddr - natmem_offset, (uae_u8*)shmaddr - natmem_offset + size, + size, size >> 10, GetLastError ()); + } else { + shmids[shmid].attached = result; + write_log (L"VirtualAlloc %08X - %08X %x (%dk) ok%s\n", + (uae_u8*)shmaddr - natmem_offset, (uae_u8*)shmaddr - natmem_offset + size, + size, size >> 10, p96special ? L" P96" : L""); + } + } + return result; +} + +int shmdt (const void *shmaddr) +{ + return 0; +} + +int shmget (key_t key, size_t size, int shmflg, const TCHAR *name) +{ + int result = -1; + + if((key == IPC_PRIVATE) || ((shmflg & IPC_CREAT) && (find_shmkey (key) == -1))) { + write_log (L"shmget of size %d (%dk) for %s\n", size, size >> 10, name); + if ((result = get_next_shmkey ()) != -1) { + shmids[result].size = size; + _tcscpy (shmids[result].name, name); + } else { + result = -1; + } + } + return result; +} + +int shmctl (int shmid, int cmd, struct shmid_ds *buf) +{ + int result = -1; + + if ((find_shmkey (shmid) != -1) && buf) { + switch (cmd) + { + case IPC_STAT: + *buf = shmids[shmid]; + result = 0; + break; + case IPC_RMID: + VirtualFree (shmids[shmid].attached, shmids[shmid].size, MEM_DECOMMIT); + shmids[shmid].key = -1; + shmids[shmid].name[0] = '\0'; + shmids[shmid].size = 0; + shmids[shmid].attached = 0; + shmids[shmid].mode = 0; + result = 0; + break; + } + } + return result; +} + +#endif + +int isinf (double x) +{ + const int nClass = _fpclass (x); + int result; + if (nClass == _FPCLASS_NINF || nClass == _FPCLASS_PINF) + result = 1; + else + result = 0; + return result; +} diff --git a/od-win32/opengl.c b/od-win32/opengl.cpp similarity index 100% rename from od-win32/opengl.c rename to od-win32/opengl.cpp diff --git a/od-win32/parser.c b/od-win32/parser.cpp similarity index 93% rename from od-win32/parser.c rename to od-win32/parser.cpp index 77699a7e..30df4c1a 100644 --- a/od-win32/parser.c +++ b/od-win32/parser.cpp @@ -53,6 +53,7 @@ #include "ahidsound_new.h" #include "uaeipc.h" #include "xwin.h" +#include "drawing.h" #include #include @@ -98,11 +99,11 @@ static GSAPI_INIT_WITH_ARGS ptr_gsapi_init_with_args; typedef int (CALLBACK* GSAPI_EXIT)(void *instance); static GSAPI_EXIT ptr_gsapi_exit; -typedef (CALLBACK* GSAPI_RUN_STRING_BEGIN)(void *instance, int user_errors, int *pexit_code); +typedef int (CALLBACK* GSAPI_RUN_STRING_BEGIN)(void *instance, int user_errors, int *pexit_code); static GSAPI_RUN_STRING_BEGIN ptr_gsapi_run_string_begin; -typedef (CALLBACK* GSAPI_RUN_STRING_CONTINUE)(void *instance, const char *str, unsigned int length, int user_errors, int *pexit_code); +typedef int (CALLBACK* GSAPI_RUN_STRING_CONTINUE)(void *instance, const char *str, unsigned int length, int user_errors, int *pexit_code); static GSAPI_RUN_STRING_CONTINUE ptr_gsapi_run_string_continue; -typedef (CALLBACK* GSAPI_RUN_STRING_END)(void *instance, int user_errors, int *pexit_code); +typedef int (CALLBACK* GSAPI_RUN_STRING_END)(void *instance, int user_errors, int *pexit_code); static GSAPI_RUN_STRING_END ptr_gsapi_run_string_end; static uae_u8 **psbuffer; @@ -176,7 +177,7 @@ static int openprinter_ps (void) static void *prt_thread (void *p) { - uae_u8 **buffers = p; + uae_u8 **buffers = (uae_u8**)p; int err, cnt, ok; ok = 1; @@ -189,7 +190,7 @@ static void *prt_thread (void *p) cnt = 0; while (buffers[cnt]) { uae_u8 *p = buffers[cnt]; - err = ptr_gsapi_run_string_continue (gsinstance, p + 2, (p[0] << 8) | p[1], 0, &gs_exitcode); + err = ptr_gsapi_run_string_continue (gsinstance, (char*)p + 2, (p[0] << 8) | p[1], 0, &gs_exitcode); if (err != e_NeedInput && err <= e_Fatal) { ptr_gsapi_exit (gsinstance); write_log (L"PostScript parsing failed.\n"); @@ -245,8 +246,8 @@ static void flushprtbuf (void) if (psmode) { uae_u8 *p; - psbuffer = realloc (psbuffer, (psbuffers + 2) * sizeof (uae_u8*)); - p = malloc (prtbufbytes + 2); + psbuffer = xrealloc (uae_u8*, psbuffer, (psbuffers + 2)); + p = xmalloc (uae_u8, prtbufbytes + 2); p[0] = prtbufbytes >> 8; p[1] = prtbufbytes; memcpy (p + 2, prtbuf, prtbufbytes); @@ -332,7 +333,7 @@ static void DoSomeWeirdPrintingStuff (uae_char val) prtdump = zfile_fopen (L"psdump.dat", L"wb", 0); psmode = 1; - psbuffer = malloc (sizeof (uae_u8*)); + psbuffer = xmalloc (uae_u8*, 1); psbuffer[0] = 0; psbuffers = 0; strcpy (prtbuf, "%!PS"); @@ -481,7 +482,7 @@ static void openprinter (void) DocInfo.pOutputFile = NULL; DocInfo.pDatatype = (currprefs.parallel_matrix_emulation || currprefs.parallel_postscript_detection) ? L"TEXT" : L"RAW"; // Inform the spooler the document is beginning. - if ((dwJob = StartDocPrinter (hPrt, 1, (LPSTR)&DocInfo)) == 0) { + if ((dwJob = StartDocPrinter (hPrt, 1, (LPBYTE)&DocInfo)) == 0) { ClosePrinter (hPrt ); hPrt = INVALID_HANDLE_VALUE; } else if (StartPagePrinter (hPrt)) { @@ -557,16 +558,18 @@ int uaeser_getdatalenght (void) return sizeof (struct uaeserialdatawin32); } -static void uaeser_initdata (struct uaeserialdatawin32 *sd, void *user) +static void uaeser_initdata (void *vsd, void *user) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; memset (sd, 0, sizeof (struct uaeserialdatawin32)); sd->hCom = INVALID_HANDLE_VALUE; sd->evtr = sd->evtw = sd->evtt = sd->evtwce = 0; sd->user = user; } -int uaeser_query (struct uaeserialdatawin32 *sd, uae_u16 *status, uae_u32 *pending) +int uaeser_query (void *vsd, uae_u16 *status, uae_u32 *pending) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; DWORD err, modem; COMSTAT ComStat; uae_u16 s = 0; @@ -587,8 +590,9 @@ int uaeser_query (struct uaeserialdatawin32 *sd, uae_u16 *status, uae_u32 *pendi return 1; } -int uaeser_break (struct uaeserialdatawin32 *sd, int brklen) +int uaeser_break (void *vsd, int brklen) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; if (!SetCommBreak (sd->hCom)) return 0; Sleep (brklen / 1000); @@ -596,8 +600,9 @@ int uaeser_break (struct uaeserialdatawin32 *sd, int brklen) return 1; } -int uaeser_setparams (struct uaeserialdatawin32 *sd, int baud, int rbuffer, int bits, int sbits, int rtscts, int parity, uae_u32 xonxoff) +int uaeser_setparams (void *vsd, int baud, int rbuffer, int bits, int sbits, int rtscts, int parity, uae_u32 xonxoff) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; DCB dcb; memset (&dcb, 0, sizeof (dcb)); @@ -658,10 +663,10 @@ static void startwce(struct uaeserialdatawin32 *sd, DWORD *evtmask) static void *uaeser_trap_thread (void *arg) { - struct uaeserialdatawin32 *sd = arg; + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)arg; HANDLE handles[4]; - int cnt, actual; - DWORD evtmask; + int cnt; + DWORD evtmask, actual; uae_set_thread_priority (NULL, 1); sd->threadactive = 1; @@ -699,13 +704,15 @@ static void *uaeser_trap_thread (void *arg) return 0; } -void uaeser_trigger (struct uaeserialdatawin32 *sd) +void uaeser_trigger (void *vsd) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; SetEvent (sd->evtt); } -int uaeser_write (struct uaeserialdatawin32 *sd, uae_u8 *data, uae_u32 len) +int uaeser_write (void *vsd, uae_u8 *data, uae_u32 len) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; int ret = 1; if (!WriteFile (sd->hCom, data, len, NULL, &sd->olw)) { sd->writeactive = 1; @@ -718,8 +725,9 @@ int uaeser_write (struct uaeserialdatawin32 *sd, uae_u8 *data, uae_u32 len) return ret; } -int uaeser_read (struct uaeserialdatawin32 *sd, uae_u8 *data, uae_u32 len) +int uaeser_read (void *vsd, uae_u8 *data, uae_u32 len) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; int ret = 1; DWORD err; COMSTAT ComStat; @@ -738,13 +746,15 @@ int uaeser_read (struct uaeserialdatawin32 *sd, uae_u8 *data, uae_u32 len) return ret; } -void uaeser_clearbuffers (struct uaeserialdatawin32 *sd) +void uaeser_clearbuffers (void *vsd) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; PurgeComm (sd->hCom, PURGE_TXCLEAR | PURGE_RXCLEAR); } -int uaeser_open (struct uaeserialdatawin32 *sd, void *user, int unit) +int uaeser_open (void *vsd, void *user, int unit) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; TCHAR buf[256]; COMMTIMEOUTS CommTimeOuts; @@ -790,8 +800,9 @@ end: return 0; } -void uaeser_close (struct uaeserialdatawin32 *sd) +void uaeser_close (void *vsd) { + struct uaeserialdatawin32 *sd = (struct uaeserialdatawin32*)vsd; if (sd->threadactive) { sd->threadactive = -1; SetEvent (sd->evtt); @@ -821,7 +832,7 @@ static uae_u8 inputbuffer[SERIAL_READ_BUFFER]; static int datainoutput; static int dataininput, dataininputcnt; static OVERLAPPED writeol, readol; -static writepending; +static int writepending; int openser (TCHAR *sername) { @@ -1200,7 +1211,7 @@ static int enumserialports_2 (int cnt) if(hDevInfo == INVALID_HANDLE_VALUE) return 0; // Enumerate the serial ports - pDetData = xmalloc (dwDetDataSize); + pDetData = (SP_DEVICE_INTERFACE_DETAIL_DATA*)xmalloc (uae_u8, dwDetDataSize); // This is required, according to the documentation. Yes, // it's weird. ifcData.cbSize = sizeof (SP_DEVICE_INTERFACE_DATA); @@ -1228,7 +1239,7 @@ static int enumserialports_2 (int cnt) comports[cnt].name = my_strdup (fname); p = _tcsstr (fname, L"(COM"); if (p && (p[5] == ')' || p[6] == ')')) { - comports[cnt].cfgname = xmalloc (100 * sizeof (TCHAR)); + comports[cnt].cfgname = xmalloc (TCHAR, 100); if (isdigit(p[5])) _stprintf (comports[cnt].cfgname, L"COM%c%c", p[4], p[5]); else @@ -1291,7 +1302,7 @@ int enumserialports (void) if (j == cnt) { if (cnt >= MAX_SERIAL_PORTS) break; - comports[j].dev = xmalloc (100 * sizeof (TCHAR)); + comports[j].dev = xmalloc (TCHAR, 100); _stprintf (comports[cnt].dev, L"\\.\\\\%s", name); comports[j].cfgname = my_strdup (name); comports[j].name = my_strdup (name); diff --git a/od-win32/picasso96_win.c b/od-win32/picasso96_win.cpp similarity index 98% rename from od-win32/picasso96_win.c rename to od-win32/picasso96_win.cpp index 08ff887e..61d35ec1 100644 --- a/od-win32/picasso96_win.c +++ b/od-win32/picasso96_win.cpp @@ -402,7 +402,7 @@ static int CopyRenderInfoStructureA2U (uaecptr amigamemptr, struct RenderInfo *r if (valid_address (memp, PSSO_RenderInfo_sizeof)) { ri->Memory = get_real_address (memp); ri->BytesPerRow = get_word (amigamemptr + PSSO_RenderInfo_BytesPerRow); - ri->RGBFormat = get_long (amigamemptr + PSSO_RenderInfo_RGBFormat); + ri->RGBFormat = (RGBFTYPE)get_long (amigamemptr + PSSO_RenderInfo_RGBFormat); return 1; } write_log (L"ERROR - Invalid RenderInfo memory area...\n"); @@ -971,50 +971,50 @@ void picasso_refresh (void) #define BLT_MULT 1 #define BLT_NAME BLIT_FALSE_32 #define BLT_FUNC(s,d) *d = 0 -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOR_32 #define BLT_FUNC(s,d) *d = ~(*s | * d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYDST_32 #define BLT_FUNC(s,d) *d = (*d) & ~(*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTSRC_32 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYSRC_32 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTDST_32 #define BLT_FUNC(s,d) *d = ~(*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_EOR_32 #define BLT_FUNC(s,d) *d = (*s) ^ (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NAND_32 #define BLT_FUNC(s,d) *d = ~((*s) & (*d)) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_AND_32 #define BLT_FUNC(s,d) *d = (*s) & (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NEOR_32 #define BLT_FUNC(s,d) *d = ~((*s) ^ (*d)) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTONLYSRC_32 #define BLT_FUNC(s,d) *d = ~(*s) | (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTONLYDST_32 #define BLT_FUNC(s,d) *d = ~(*d) | (*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_OR_32 #define BLT_FUNC(s,d) *d = (*s) | (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_TRUE_32 #define BLT_FUNC(s,d) *d = 0xffffffff -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_30_32 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp; #define BLT_TEMP -#include "p96_blit.c" +#include "p96_blit.cpp" #undef BLT_SIZE #undef BLT_MULT @@ -1022,50 +1022,50 @@ void picasso_refresh (void) #define BLT_MULT 1 #define BLT_NAME BLIT_FALSE_24 #define BLT_FUNC(s,d) *d = 0 -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOR_24 #define BLT_FUNC(s,d) *d = ~(*s | * d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYDST_24 #define BLT_FUNC(s,d) *d = (*d) & ~(*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTSRC_24 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYSRC_24 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTDST_24 #define BLT_FUNC(s,d) *d = ~(*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_EOR_24 #define BLT_FUNC(s,d) *d = (*s) ^ (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NAND_24 #define BLT_FUNC(s,d) *d = ~((*s) & (*d)) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_AND_24 #define BLT_FUNC(s,d) *d = (*s) & (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NEOR_24 #define BLT_FUNC(s,d) *d = ~((*s) ^ (*d)) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTONLYSRC_24 #define BLT_FUNC(s,d) *d = ~(*s) | (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTONLYDST_24 #define BLT_FUNC(s,d) *d = ~(*d) | (*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_OR_24 #define BLT_FUNC(s,d) *d = (*s) | (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_TRUE_24 #define BLT_FUNC(s,d) *d = 0xffffffff -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_30_24 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp; #define BLT_TEMP -#include "p96_blit.c" +#include "p96_blit.cpp" #undef BLT_SIZE #undef BLT_MULT @@ -1073,50 +1073,50 @@ void picasso_refresh (void) #define BLT_MULT 2 #define BLT_NAME BLIT_FALSE_16 #define BLT_FUNC(s,d) *d = 0 -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOR_16 #define BLT_FUNC(s,d) *d = ~(*s | * d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYDST_16 #define BLT_FUNC(s,d) *d = (*d) & ~(*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTSRC_16 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYSRC_16 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTDST_16 #define BLT_FUNC(s,d) *d = ~(*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_EOR_16 #define BLT_FUNC(s,d) *d = (*s) ^ (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NAND_16 #define BLT_FUNC(s,d) *d = ~((*s) & (*d)) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_AND_16 #define BLT_FUNC(s,d) *d = (*s) & (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NEOR_16 #define BLT_FUNC(s,d) *d = ~((*s) ^ (*d)) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTONLYSRC_16 #define BLT_FUNC(s,d) *d = ~(*s) | (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTONLYDST_16 #define BLT_FUNC(s,d) *d = ~(*d) | (*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_OR_16 #define BLT_FUNC(s,d) *d = (*s) | (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_TRUE_16 #define BLT_FUNC(s,d) *d = 0xffffffff -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_30_16 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp; #define BLT_TEMP -#include "p96_blit.c" +#include "p96_blit.cpp" #undef BLT_SIZE #undef BLT_MULT @@ -1124,50 +1124,50 @@ void picasso_refresh (void) #define BLT_MULT 4 #define BLT_NAME BLIT_FALSE_8 #define BLT_FUNC(s,d) *d = 0 -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOR_8 #define BLT_FUNC(s,d) *d = ~(*s | * d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYDST_8 #define BLT_FUNC(s,d) *d = (*d) & ~(*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTSRC_8 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYSRC_8 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTDST_8 #define BLT_FUNC(s,d) *d = ~(*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_EOR_8 #define BLT_FUNC(s,d) *d = (*s) ^ (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NAND_8 #define BLT_FUNC(s,d) *d = ~((*s) & (*d)) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_AND_8 #define BLT_FUNC(s,d) *d = (*s) & (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NEOR_8 #define BLT_FUNC(s,d) *d = ~((*s) ^ (*d)) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTONLYSRC_8 #define BLT_FUNC(s,d) *d = ~(*s) | (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_NOTONLYDST_8 #define BLT_FUNC(s,d) *d = ~(*d) | (*s) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_OR_8 #define BLT_FUNC(s,d) *d = (*s) | (*d) -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_TRUE_8 #define BLT_FUNC(s,d) *d = 0xffffffff -#include "p96_blit.c" +#include "p96_blit.cpp" #define BLT_NAME BLIT_30_8 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp; #define BLT_TEMP -#include "p96_blit.c" +#include "p96_blit.cpp" #undef BLT_SIZE #undef BLT_MULT @@ -1598,8 +1598,8 @@ int createwindowscursor (uaecptr src, int w, int h, int hiressprite, int doubled xorBM = CreateCompatibleBitmap (DC, w2, h2); if (!andBM || !xorBM) goto end; - andoBM = SelectObject (andDC, andBM); - xoroBM = SelectObject (xorDC, xorBM); + andoBM = (HBITMAP)SelectObject (andDC, andBM); + xoroBM = (HBITMAP)SelectObject (xorDC, xorBM); isdata = 0; for (y = 0, yy = 0; y < h2; yy++) { @@ -1653,7 +1653,7 @@ end: wincursor = CreateIconIndirect (&ic); tmp_sprite_w = w; tmp_sprite_h = h; - tmp_sprite_data = xmalloc (datasize); + tmp_sprite_data = xmalloc (uae_u8, datasize); tmp_sprite_hires = hiressprite; tmp_sprite_doubled = doubledsprite; memcpy (tmp_sprite_data, realsrc, datasize); @@ -1746,7 +1746,7 @@ static uae_u32 setspriteimage (uaecptr bi) createwindowscursor (get_long (bi + PSSO_BoardInfo_MouseImage) + 4 * hiressprite, w, h, hiressprite, doubledsprite, 0); - tmpbuf = xmalloc (w * h * bpp); + tmpbuf = xmalloc (uae_u8, w * h * bpp); for (y = 0, yy = 0; y < h; y++, yy++) { uae_u8 *p = tmpbuf + w * bpp * y; uae_u8 *pprev = p; @@ -2100,7 +2100,7 @@ static void init_alloc (void) gwwpagesize = si.dwPageSize; gwwbufsize = allocated_gfxmem / gwwpagesize + 1; gwwpagemask = gwwpagesize - 1; - gwwbuf = xmalloc (gwwbufsize * sizeof (void*)); + gwwbuf = xmalloc (void*, gwwbufsize); } static int p96depth (int depth) @@ -2141,7 +2141,7 @@ void picasso96_alloc (TrapContext *ctx) return; misscnt = 0; cnt = 0; - newmodes = xmalloc (sizeof (struct PicassoResolution) * MAX_PICASSO_MODES); + newmodes = xmalloc (struct PicassoResolution, MAX_PICASSO_MODES); size = 0; depths = 0; @@ -2757,7 +2757,7 @@ static uae_u32 REGPARAM2 picasso_SetPanning (TrapContext *ctx) put_word (bi + PSSO_BoardInfo_YOffset, picasso96_state.YOffset); picasso96_state.VirtualWidth = bme_width; picasso96_state.VirtualHeight = bme_height; - picasso96_state.RGBFormat = m68k_dreg (regs, 7); + picasso96_state.RGBFormat = (RGBFTYPE)m68k_dreg (regs, 7); picasso96_state.BytesPerPixel = GetBytesPerPixel (picasso96_state.RGBFormat); picasso96_state.BytesPerRow = picasso96_state.VirtualWidth * picasso96_state.BytesPerPixel; picasso_SetPanningInit(); @@ -2871,7 +2871,7 @@ static uae_u32 REGPARAM2 picasso_FillRect (TrapContext *ctx) 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); - RGBFTYPE RGBFormat = m68k_dreg (regs, 7); + RGBFTYPE RGBFormat = (RGBFTYPE)m68k_dreg (regs, 7); uae_u8 *oldstart; int Bpp; struct RenderInfo ri; @@ -3083,7 +3083,7 @@ static uae_u32 REGPARAM2 picasso_BlitRectNoMaskComplete (TrapContext *ctx) unsigned long dsty = (uae_u16)m68k_dreg (regs, 3); unsigned long width = (uae_u16)m68k_dreg (regs, 4); unsigned long height = (uae_u16)m68k_dreg (regs, 5); - uae_u8 OpCode = m68k_dreg (regs, 6); + BLIT_OPCODE OpCode = (BLIT_OPCODE)(m68k_dreg (regs, 6) & 0xff); uae_u32 RGBFmt = m68k_dreg (regs, 7); uae_u32 result = 0; @@ -4159,7 +4159,7 @@ static void flushpixels (void) } for (i = 0; i < gwwcnt; i++) { - uae_u8 *p = gwwbuf[i]; + uae_u8 *p = (uae_u8*)gwwbuf[i]; if (p >= src_start && p < src_end) { int y, x, realoffset; @@ -4756,7 +4756,7 @@ uae_u8 *restore_p96 (uae_u8 *src) interrupt_enabled = !!(flags & 32); changed_prefs.gfxmem_size = restore_u32 (); picasso96_state.Address = restore_u32 (); - picasso96_state.RGBFormat = restore_u32 (); + picasso96_state.RGBFormat = (RGBFTYPE)restore_u32 (); picasso96_state.Width = restore_u16 (); picasso96_state.Height = restore_u16 (); picasso96_state.VirtualWidth = restore_u16 (); @@ -4788,7 +4788,7 @@ uae_u8 *save_p96 (int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = malloc (1000); + dstbak = dst = xmalloc (uae_u8, 1000); save_u32 (2); save_u32 ((picasso_on ? 1 : 0) | (set_gc_called ? 2 : 0) | (set_panning_called ? 4 : 0) | (hwsprite ? 8 : 0) | (cursorvisible ? 16 : 0) | (interrupt_enabled ? 32 : 0)); diff --git a/od-win32/picasso96_win.h b/od-win32/picasso96_win.h index a49cca06..c3fc6e43 100644 --- a/od-win32/picasso96_win.h +++ b/od-win32/picasso96_win.h @@ -228,7 +228,7 @@ struct RenderInfo { #define PSSO_Pattern_DrawMode 17 #define PSSO_Pattern_sizeof 18 struct Pattern { - char *Memory; + uae_u8 *Memory; uae_u16 XOffset, YOffset; uae_u32 FgPen, BgPen; uae_u8 Size; /* Width: 16, Height: (1<f; void *arg = thp->arg; @@ -275,7 +275,7 @@ int uae_start_thread (TCHAR *name, void *(*f)(void *), void *arg, uae_thread_id unsigned foo; struct thparms *thp; - thp = xmalloc (sizeof (struct thparms)); + thp = xmalloc (struct thparms, 1); thp->f = f; thp->arg = arg; hThread = (HANDLE)_beginthreadex (NULL, 0, thread_init, thp, 0, &foo); diff --git a/od-win32/registry.c b/od-win32/registry.cpp similarity index 87% rename from od-win32/registry.c rename to od-win32/registry.cpp index a291666f..3ddb979a 100644 --- a/od-win32/registry.c +++ b/od-win32/registry.cpp @@ -3,8 +3,8 @@ #include "sysdeps.h" #include -#include "win32.h" #include +#include "win32.h" #include "registry.h" #include "crc32.h" @@ -30,7 +30,7 @@ static TCHAR *gsn (UAEREG *root, const TCHAR *name) if (!root) return my_strdup (name); r = gs (root); - s = xmalloc ((_tcslen (r) + 1 + _tcslen (name) + 1) * sizeof (TCHAR)); + s = xmalloc (TCHAR, _tcslen (r) + 1 + _tcslen (name) + 1); _stprintf (s, L"%s/%s", r, name); return s; } @@ -91,7 +91,7 @@ int regquerystr (UAEREG *root, const TCHAR *name, TCHAR *str, int *size) { if (inimode) { int ret = 0; - TCHAR *tmp = xmalloc (((*size) + 1) * sizeof (TCHAR)); + TCHAR *tmp = xmalloc (TCHAR, (*size) + 1); GetPrivateProfileString (gs (root), name, PUPPA, tmp, *size, inipath); if (_tcscmp (tmp, PUPPA)) { _tcscpy (str, tmp); @@ -100,10 +100,13 @@ int regquerystr (UAEREG *root, const TCHAR *name, TCHAR *str, int *size) xfree (tmp); return ret; } else { + DWORD size2 = *size; HKEY rk = gr (root); if (!rk) return 0; - return RegQueryValueEx (rk, name, 0, NULL, (LPBYTE)str, size) == ERROR_SUCCESS; + int v = RegQueryValueEx (rk, name, 0, NULL, (LPBYTE)str, &size2) == ERROR_SUCCESS; + *size = size2; + return v; } } @@ -114,7 +117,7 @@ int regenumstr (UAEREG *root, int idx, TCHAR *name, int *nsize, TCHAR *str, int if (inimode) { int ret = 0; int tmpsize = 65536; - TCHAR *tmp = xmalloc (tmpsize * sizeof (TCHAR)); + TCHAR *tmp = xmalloc (TCHAR, tmpsize); if (GetPrivateProfileSection (gs (root), tmp, tmpsize, inipath) > 0) { int i; TCHAR *p = tmp, *p2; @@ -134,10 +137,15 @@ int regenumstr (UAEREG *root, int idx, TCHAR *name, int *nsize, TCHAR *str, int xfree (tmp); return ret; } else { + DWORD nsize2 = *nsize; + DWORD size2 = *size; HKEY rk = gr (root); if (!rk) return 0; - return RegEnumValue (rk, idx, name, nsize, NULL, NULL, (LPBYTE)str, size) == ERROR_SUCCESS; + int v = RegEnumValue (rk, idx, name, &nsize2, NULL, NULL, (LPBYTE)str, &size2) == ERROR_SUCCESS; + *nsize = nsize2; + *size = size2; + return v; } } @@ -146,7 +154,7 @@ int regquerydatasize (UAEREG *root, const TCHAR *name, int *size) if (inimode) { int ret = 0; int csize = 65536; - TCHAR *tmp = xmalloc (csize * sizeof (TCHAR)); + TCHAR *tmp = xmalloc (TCHAR, csize); if (regquerystr (root, name, tmp, &csize)) { *size = _tcslen (tmp) / 2; ret = 1; @@ -157,17 +165,20 @@ int regquerydatasize (UAEREG *root, const TCHAR *name, int *size) HKEY rk = gr (root); if (!rk) return 0; - return RegQueryValueEx(rk, name, 0, NULL, NULL, size) == ERROR_SUCCESS; + DWORD size2 = *size; + int v = RegQueryValueEx(rk, name, 0, NULL, NULL, &size2) == ERROR_SUCCESS; + *size = size2; + return v; } } -int regsetdata (UAEREG *root, const TCHAR *name, void *str, int size) +int regsetdata (UAEREG *root, const TCHAR *name, const void *str, int size) { if (inimode) { - uae_u8 *in = str; + uae_u8 *in = (uae_u8*)str; DWORD ret; int i; - TCHAR *tmp = xmalloc ((size * 2 + 1) * sizeof (TCHAR)); + TCHAR *tmp = xmalloc (TCHAR, size * 2 + 1); for (i = 0; i < size; i++) _stprintf (tmp + i * 2, L"%02X", in[i]); ret = WritePrivateProfileString (gs (root), name, tmp, inipath); @@ -186,8 +197,8 @@ int regquerydata (UAEREG *root, const TCHAR *name, void *str, int *size) int csize = (*size) * 2 + 1; int i, j; int ret = 0; - TCHAR *tmp = xmalloc (csize * sizeof (TCHAR)); - uae_u8 *out = str; + TCHAR *tmp = xmalloc (TCHAR, csize); + uae_u8 *out = (uae_u8*)str; if (!regquerystr (root, name, tmp, &csize)) goto err; @@ -217,7 +228,10 @@ err: HKEY rk = gr (root); if (!rk) return 0; - return RegQueryValueEx(rk, name, 0, NULL, str, size) == ERROR_SUCCESS; + DWORD size2 = *size; + int v = RegQueryValueEx(rk, name, 0, NULL, (LPBYTE)str, &size2) == ERROR_SUCCESS; + *size = size2; + return v; } } @@ -238,7 +252,7 @@ int regexists (UAEREG *root, const TCHAR *name) { if (inimode) { int ret = 1; - TCHAR *tmp = xmalloc ((_tcslen (PUPPA) + 1) * sizeof (TCHAR)); + TCHAR *tmp = xmalloc (TCHAR, _tcslen (PUPPA) + 1); int size = _tcslen (PUPPA) + 1; GetPrivateProfileString (gs (root), name, PUPPA, tmp, size, inipath); if (!_tcscmp (tmp, PUPPA)) @@ -278,7 +292,7 @@ int regexiststree (UAEREG *root, const TCHAR *name) TCHAR *s = gsn (root, name); if (!s) return 0; - tmp = xmalloc (tmpsize); + tmp = xmalloc (TCHAR, tmpsize / sizeof (TCHAR)); tmp[0] = 0; GetPrivateProfileSectionNames (tmp, tmpsize, inipath); p = tmp; @@ -320,10 +334,10 @@ UAEREG *regcreatetree (UAEREG *root, const TCHAR *name) else ininame = my_strdup (name); } else { - ininame = xmalloc ((_tcslen (root->inipath) + 1 + _tcslen (name) + 1) * sizeof (TCHAR)); + ininame = xmalloc (TCHAR, _tcslen (root->inipath) + 1 + _tcslen (name) + 1); _stprintf (ininame, L"%s/%s", root->inipath, name); } - fkey = xcalloc (sizeof (UAEREG), 1); + fkey = xcalloc (UAEREG, 1); fkey->inipath = ininame; } else { DWORD err; @@ -338,7 +352,7 @@ UAEREG *regcreatetree (UAEREG *root, const TCHAR *name) KEY_READ | KEY_WRITE, NULL, &rkey, NULL); if (err != ERROR_SUCCESS) return 0; - fkey = xcalloc (sizeof (UAEREG), 1); + fkey = xcalloc (UAEREG, 1); fkey->fkey = rkey; } return fkey; diff --git a/od-win32/rp.c b/od-win32/rp.cpp similarity index 99% rename from od-win32/rp.c rename to od-win32/rp.cpp index ef303f31..c74888bc 100644 --- a/od-win32/rp.c +++ b/od-win32/rp.cpp @@ -827,7 +827,7 @@ static void rp_device_change (int dev, int num, const TCHAR *name) if (name != NULL) _tcscpy (np, name); dc_size = sizeof (struct RPDeviceContent) + (_tcslen (np) + 1) * sizeof (TCHAR); - dc = xcalloc (dc_size, 1); + dc = (RPDeviceContent*)xcalloc (uae_u8, dc_size); dc->btDeviceCategory = dev; dc->btDeviceNumber = num; _tcscpy (dc->szContent, np); diff --git a/od-win32/scaler.c b/od-win32/scaler.cpp similarity index 99% rename from od-win32/scaler.c rename to od-win32/scaler.cpp index 51be377d..0bc947f6 100644 --- a/od-win32/scaler.c +++ b/od-win32/scaler.cpp @@ -15,6 +15,11 @@ /* Scaler (except Scale2x) code borrowed from ScummVM project */ +extern int cpu_mmx; + +extern "C" +{ + #include "sysconfig.h" #include "sysdeps.h" @@ -845,7 +850,6 @@ void _2xSaI_32(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPi */ #define MMX -extern int cpu_mmx; /* Suggested in "Intel Optimization" for Pentium II */ #define ASM_JUMP_ALIGN ".p2align 4\n" @@ -1886,3 +1890,4 @@ void hq_init (int rb, int gb, int bb, int rs, int gs, int bs) } } +} diff --git a/od-win32/scaler2.c b/od-win32/scaler2.cpp similarity index 100% rename from od-win32/scaler2.c rename to od-win32/scaler2.cpp diff --git a/od-win32/scaler_more.c b/od-win32/scaler_more.cpp similarity index 100% rename from od-win32/scaler_more.c rename to od-win32/scaler_more.cpp diff --git a/od-win32/screenshot.c b/od-win32/screenshot.cpp similarity index 96% rename from od-win32/screenshot.c rename to od-win32/screenshot.cpp index 02174cd6..07c075dc 100644 --- a/od-win32/screenshot.c +++ b/od-win32/screenshot.cpp @@ -21,7 +21,7 @@ #include "png.h" int screenshotmode = PNG_SCREENSHOTS; -DWORD screenshot_originalsize = 0; +int screenshot_originalsize = 0; static void namesplit (TCHAR *s) { @@ -52,7 +52,7 @@ static int toclipboard (BITMAPINFO *bi, void *bmp) EmptyClipboard (); hg = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, bi->bmiHeader.biSize + bi->bmiHeader.biSizeImage); if (hg) { - dib = GlobalLock (hg); + dib = (uae_u8*)GlobalLock (hg); if (dib) { memcpy (dib, &bi->bmiHeader, bi->bmiHeader.biSize); memcpy (dib + bi->bmiHeader.biSize, bmp, bi->bmiHeader.biSizeImage); @@ -94,7 +94,7 @@ static int rgb_rb, rgb_gb, rgb_bb, rgb_rs, rgb_gs, rgb_bs; int screenshot_prepare (void) { - unsigned int width, height; + int width, height; HGDIOBJ hgdiobj; int bits; @@ -122,7 +122,7 @@ int screenshot_prepare (void) bi.bmiHeader.biYPelsPerMeter = 0; bi.bmiHeader.biClrUsed = 0; bi.bmiHeader.biClrImportant = 0; - if (!(lpvBits = xmalloc (bi.bmiHeader.biSizeImage))) + if (!(lpvBits = xmalloc (uae_u8, bi.bmiHeader.biSizeImage))) goto oops; dst = (uae_u8*)lpvBits + (height - 1) * dpitch; for (y = 0; y < height; y++) { @@ -203,7 +203,7 @@ donormal: bi.bmiHeader.biClrImportant = 0; // Reserve memory for bitmap bits - if (!(lpvBits = xmalloc (bi.bmiHeader.biSizeImage))) + if (!(lpvBits = xmalloc (uae_u8, bi.bmiHeader.biSizeImage))) goto oops; // out of memory // Have GetDIBits convert offscreen_bitmap to a DIB (device-independent bitmap): @@ -235,10 +235,11 @@ void Screenshot_RGBinfo (int rb, int gb, int bb, int rs, int gs, int bs) static void _cdecl pngtest_blah (png_structp png_ptr, png_const_charp message) { - TCHAR *name = L"unknown"; + TCHAR *name = au ("unknown"); if (png_ptr != NULL && png_ptr->error_ptr != NULL) - name = png_ptr->error_ptr; + name = au ((char*)png_ptr->error_ptr); write_log (L"%s: libpng warning: %s\n", name, message); + xfree (name); } static int savepng (FILE *fp) @@ -268,7 +269,7 @@ static int savepng (FILE *fp) png_set_IHDR (png_ptr, info_ptr, w, h, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - row_pointers = xmalloc (h * sizeof (png_bytep*)); + row_pointers = xmalloc (png_bytep, h); for (i = 0; i < h; i++) { int j = h - i - 1; row_pointers[i] = (uae_u8*)lpvBits + j * (((w * 24 + 31) & ~31) / 8); diff --git a/od-win32/serial_win32.c b/od-win32/serial_win32.cpp similarity index 99% rename from od-win32/serial_win32.c rename to od-win32/serial_win32.cpp index c62c9bdf..c8a5faff 100644 --- a/od-win32/serial_win32.c +++ b/od-win32/serial_win32.cpp @@ -578,7 +578,7 @@ static void enet_service (int serveronly) { uae_u8 *p = evt.packet->data; int len = evt.packet->dataLength; - if (len == 6 && !strncmp (p, "UAE_", 4)) { + if (len == 6 && !memcmp (p, "UAE_", 4)) { if (((enet_receive_off_w + 1) & 0xff) != enet_receive_off_r) { enet_receive[enet_receive_off_w++] = (p[4] << 8) | p[5]; } @@ -720,7 +720,7 @@ int enet_open (TCHAR *name) enet_close (); return 0; } - strcpy (data, "UAE_HELLO"); + memcpy (data, "UAE_HELLO", 10); p = enet_packet_create (data, sizeof data, ENET_PACKET_FLAG_RELIABLE); enet_peer_send (enetpeer, 0, p); enet_host_flush (enetclient); @@ -734,7 +734,7 @@ void enet_writeser (uae_u16 w) ENetPacket *p; uae_u8 data[16]; - strcpy (data, "UAE_"); + memcpy (data, "UAE_", 4); data[4] = w >> 8; data[5] = w >> 0; write_log (L"W=%04X ", w); diff --git a/od-win32/sfhelper.c b/od-win32/sfhelper.cpp similarity index 100% rename from od-win32/sfhelper.c rename to od-win32/sfhelper.cpp diff --git a/od-win32/shm.c b/od-win32/shm.cpp similarity index 100% rename from od-win32/shm.c rename to od-win32/shm.cpp diff --git a/od-win32/soundcheck.c b/od-win32/soundcheck.cpp similarity index 100% rename from od-win32/soundcheck.c rename to od-win32/soundcheck.cpp diff --git a/od-win32/sounddep/sound.c b/od-win32/sounddep/sound.cpp similarity index 90% rename from od-win32/sounddep/sound.c rename to od-win32/sounddep/sound.cpp index 8c491bad..0464972d 100644 --- a/od-win32/sounddep/sound.c +++ b/od-win32/sounddep/sound.cpp @@ -53,7 +53,7 @@ struct sound_dp LPDIRECTSOUNDBUFFER8 lpDSBsecondary; DWORD writepos; int dsoundbuf; - int safedist; + DWORD safedist; int snd_writeoffset; int snd_maxoffset; int snd_totalmaxoffset_uf; @@ -97,7 +97,7 @@ struct sound_dp UINT64 wasapiclock; #endif REFERENCE_TIME hnsRequestedDuration; - int bufferFrameCount; + UINT32 bufferFrameCount; UINT64 wasapiframes; int wasapiexclusive; int framecounter; @@ -207,7 +207,7 @@ static void pause_audio_wasapi (struct sound_data *sd) struct sound_dp *s = sd->data; HRESULT hr; - hr = s->pAudioClient->lpVtbl->Stop (s->pAudioClient); + hr = s->pAudioClient->Stop (); if (FAILED (hr)) write_log (L"WASAPI: Stop() %08X\n", hr); } @@ -218,15 +218,15 @@ static void resume_audio_wasapi (struct sound_data *sd) BYTE *pData; int framecnt; - hr = s->pAudioClient->lpVtbl->Reset (s->pAudioClient); + hr = s->pAudioClient->Reset (); if (FAILED (hr)) write_log (L"WASAPI: Reset() %08X\n", hr); framecnt = s->wasapigoodsize; - hr = s->pRenderClient->lpVtbl->GetBuffer (s->pRenderClient, framecnt, &pData); + hr = s->pRenderClient->GetBuffer (framecnt, &pData); if (FAILED (hr)) return; - hr = s->pRenderClient->lpVtbl->ReleaseBuffer (s->pRenderClient, framecnt, AUDCLNT_BUFFERFLAGS_SILENT); - hr = s->pAudioClient->lpVtbl->Start (s->pAudioClient); + hr = s->pRenderClient->ReleaseBuffer (framecnt, AUDCLNT_BUFFERFLAGS_SILENT); + hr = s->pAudioClient->Start (); if (FAILED (hr)) write_log (L"WASAPI: Start() %08X\n", hr); s->wasapiframes = 0; @@ -366,8 +366,8 @@ static void recalc_offsets (struct sound_data *sd) s->snd_totalmaxoffset_uf = s->max_sndbufsize + (s->dsoundbuf - s->max_sndbufsize) * 7 / 9; } -const static GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001,0x0000,0x0010, -{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}}; +//const static GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001,0x0000,0x0010, +//{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}}; #define KSAUDIO_SPEAKER_QUAD_SURROUND (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | \ SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT) @@ -385,7 +385,7 @@ static DWORD fillsupportedmodes (struct sound_data *sd, int freq, struct dsaudio DWORD rn[4]; struct sound_dp *s = sd->data; LPDIRECTSOUND8 lpDS = s->lpDS; - static done; + static int done; if (done) return speakerconfig; @@ -475,7 +475,7 @@ static int _cdecl portAudioCallback (const void *inputBuffer, void *outputBuffer PaStreamCallbackFlags statusFlags, void *userData) { - struct sound_data *sd = userData; + struct sound_data *sd = (struct sound_data*)userData; struct sound_dp *s = sd->data; if (framesPerBuffer != sd->sndbufsize / (sd->channels * 2)) { @@ -584,7 +584,7 @@ static int open_audio_pa (struct sound_data *sd, int index) // } s->paevent = CreateEvent (NULL, FALSE, FALSE, NULL); for (i = 0; i < 2; i++) - s->pasoundbuffer[i] = xcalloc (sd->sndbufsize, 1); + s->pasoundbuffer[i] = xcalloc (uae_u8, sd->sndbufsize); name = au (di->name); write_log (L"PASOUND: CH=%d,FREQ=%d (%s) '%s' buffer %d\n", ch, freq, sound_devices[index].name, name, sd->sndbufsize); @@ -633,7 +633,7 @@ static int open_audio_al (struct sound_data *sd, int index) if (sd->sndbufsize > SND_MAX_BUFFER) sd->sndbufsize = SND_MAX_BUFFER; s->al_bufsize = size; - s->al_bigbuffer = xcalloc (s->al_bufsize, 1); + s->al_bigbuffer = xcalloc (uae_u8, s->al_bufsize); name = ua (sound_devices[index].alname); s->al_dev = alcOpenDevice (name); xfree (name); @@ -680,25 +680,19 @@ static void close_audio_wasapi (struct sound_data *sd) struct sound_dp *s = sd->data; if (s->pRenderClient) - s->pRenderClient->lpVtbl->Release (s->pRenderClient); + s->pRenderClient->Release (); #if 0 if (s->pAudioClock) - s->pAudioClock->lpVtbl->Release (s->pAudioClock); + s->pAudioClock->Release (); #endif if (s->pAudioClient) - s->pAudioClient->lpVtbl->Release (s->pAudioClient); + s->pAudioClient->Release (); if (s->pDevice) - s->pDevice->lpVtbl->Release (s->pDevice); + s->pDevice->Release (); if (s->pEnumerator) - s->pEnumerator->lpVtbl->Release (s->pEnumerator); + s->pEnumerator->Release (); } -const static GUID XIID_IAudioClient = {0x1CB9AD4C,0xDBFA,0x4c32,{0xB1,0x78,0xC2,0xF5,0x68,0xA7,0x03,0xB2}}; -const static GUID XIID_IAudioRenderClient = {0xF294ACFC,0x3146,0x4483,{0xA7,0xBF,0xAD,0xDC,0xA7,0xC2,0x60,0xE2}}; -const static GUID XIID_IMMDeviceEnumerator = {0xA95664D2,0x9614,0x4F35,{0xA7,0x46,0xDE,0x8D,0xB6,0x36,0x17,0xE6}}; -const static GUID XCLSID_MMDeviceEnumerator = {0xBCDE0395,0xE52F,0x467C,{0x8E,0x3D,0xC4,0x57,0x92,0x91,0x69,0x2E}}; -const static GUID XIID_IAudioClock = {0xCD63314F,0x3FBA,0x4a1b,{0x81,0x2C,0xEF,0x96,0x35,0x87,0x28,0xE7}}; - static int open_audio_wasapi (struct sound_data *sd, int index, int exclusive) { HRESULT hr; @@ -719,8 +713,8 @@ static int open_audio_wasapi (struct sound_data *sd, int index, int exclusive) else sharemode = AUDCLNT_SHAREMODE_SHARED; - hr = CoCreateInstance (&XCLSID_MMDeviceEnumerator, NULL, - CLSCTX_ALL, &XIID_IMMDeviceEnumerator, + hr = CoCreateInstance (__uuidof(MMDeviceEnumerator), NULL, + CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&s->pEnumerator); if (FAILED (hr)) { write_log (L"WASAPI: %d\n", hr); @@ -728,33 +722,33 @@ static int open_audio_wasapi (struct sound_data *sd, int index, int exclusive) } if (sound_devices[index].alname == NULL) - hr = s->pEnumerator->lpVtbl->GetDefaultAudioEndpoint (s->pEnumerator, eRender, eMultimedia, &s->pDevice); + hr = s->pEnumerator->GetDefaultAudioEndpoint (eRender, eMultimedia, &s->pDevice); else - hr = s->pEnumerator->lpVtbl->GetDevice (s->pEnumerator, sound_devices[index].alname, &s->pDevice); + hr = s->pEnumerator->GetDevice (sound_devices[index].alname, &s->pDevice); if (FAILED (hr)) { write_log (L"WASAPI: GetDevice(%s) %08X\n", sound_devices[index].alname ? sound_devices[index].alname : L"NULL", hr); goto error; } - hr = s->pDevice->lpVtbl->GetId (s->pDevice, &name); + hr = s->pDevice->GetId (&name); if (FAILED (hr)) { write_log (L"WASAPI: GetId() %08X\n", hr); goto error; } - hr = s->pDevice->lpVtbl->Activate (s->pDevice, &XIID_IAudioClient, CLSCTX_ALL, NULL, (void**)&s->pAudioClient); + hr = s->pDevice->Activate (__uuidof(IAudioClient), CLSCTX_ALL, NULL, (void**)&s->pAudioClient); if (FAILED (hr)) { write_log (L"WASAPI: Activate() %d\n", hr); goto error; } - hr = s->pAudioClient->lpVtbl->GetMixFormat (s->pAudioClient, &pwfx); + hr = s->pAudioClient->GetMixFormat (&pwfx); if (FAILED (hr)) { write_log (L"WASAPI: GetMixFormat() %08X\n", hr); goto error; } - hr = s->pAudioClient->lpVtbl->GetDevicePeriod (s->pAudioClient, NULL, &s->hnsRequestedDuration); + hr = s->pAudioClient->GetDevicePeriod (NULL, &s->hnsRequestedDuration); if (FAILED (hr)) { write_log (L"WASAPI: GetDevicePeriod() %08X\n", hr); goto error; @@ -795,7 +789,7 @@ static int open_audio_wasapi (struct sound_data *sd, int index, int exclusive) wavfmt.Format.nAvgBytesPerSec = wavfmt.Format.nBlockAlign * wavfmt.Format.nSamplesPerSec; CoTaskMemFree (pwfx); pwfx = NULL; - hr = s->pAudioClient->lpVtbl->IsFormatSupported (s->pAudioClient, sharemode, &wavfmt.Format, &pwfx); + hr = s->pAudioClient->IsFormatSupported (sharemode, &wavfmt.Format, &pwfx); if (SUCCEEDED (hr) && hr != S_FALSE) break; write_log (L"WASAPI: IsFormatSupported(%d,%08X,%d) (%d,%d) %08X\n", @@ -867,16 +861,15 @@ static int open_audio_wasapi (struct sound_data *sd, int index, int exclusive) ); } - hr = s->pAudioClient->lpVtbl->Initialize (s->pAudioClient, - sharemode, AUDCLNT_STREAMFLAGS_NOPERSIST, + hr = s->pAudioClient->Initialize (sharemode, AUDCLNT_STREAMFLAGS_NOPERSIST, s->hnsRequestedDuration, s->wasapiexclusive ? s->hnsRequestedDuration : 0, pwfx ? pwfx : &wavfmt.Format, NULL); if (hr == AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED) { - hr = s->pAudioClient->lpVtbl->GetBufferSize (s->pAudioClient, &s->bufferFrameCount); + hr = s->pAudioClient->GetBufferSize (&s->bufferFrameCount); if (FAILED (hr)) { write_log (L"WASAPI: GetBufferSize() %08X\n", hr); goto error; } - s->pAudioClient->lpVtbl->Release (s->pAudioClient); + s->pAudioClient->Release (); s->hnsRequestedDuration = // hns = (REFERENCE_TIME)( 10000.0 * // (hns / ms) * @@ -886,13 +879,12 @@ static int open_audio_wasapi (struct sound_data *sd, int index, int exclusive) + 0.5 // rounding ); s->hnsRequestedDuration *= sd->sndbufsize / 512; - hr = s->pDevice->lpVtbl->Activate (s->pDevice, &XIID_IAudioClient, CLSCTX_ALL, NULL, (void**)&s->pAudioClient); + hr = s->pDevice->Activate (__uuidof(IAudioClient), CLSCTX_ALL, NULL, (void**)&s->pAudioClient); if (FAILED (hr)) { write_log (L"WASAPI: Activate() %08X\n", hr); goto error; } - hr = s->pAudioClient->lpVtbl->Initialize (s->pAudioClient, - sharemode, AUDCLNT_STREAMFLAGS_NOPERSIST, + hr = s->pAudioClient->Initialize (sharemode, AUDCLNT_STREAMFLAGS_NOPERSIST, s->hnsRequestedDuration, s->wasapiexclusive ? s->hnsRequestedDuration : 0, pwfx ? pwfx : &wavfmt.Format, NULL); } if (FAILED (hr)) { @@ -900,7 +892,7 @@ static int open_audio_wasapi (struct sound_data *sd, int index, int exclusive) goto error; } - hr = s->pAudioClient->lpVtbl->GetBufferSize (s->pAudioClient, &s->bufferFrameCount); + hr = s->pAudioClient->GetBufferSize (&s->bufferFrameCount); if (FAILED (hr)) { write_log (L"WASAPI: GetBufferSize() %08X\n", hr); goto error; @@ -915,17 +907,17 @@ static int open_audio_wasapi (struct sound_data *sd, int index, int exclusive) + 0.5 // rounding ); - hr = s->pAudioClient->lpVtbl->GetService (s->pAudioClient, &XIID_IAudioRenderClient, (void**)&s->pRenderClient); + hr = s->pAudioClient->GetService (__uuidof(IAudioRenderClient), (void**)&s->pRenderClient); if (FAILED (hr)) { - write_log (L"WASAPI: GetService(IID_IAudioRenderClient) %08X\n", hr); + write_log (L"WASAPI: GetService(IAudioRenderClient) %08X\n", hr); goto error; } #if 0 - hr = s->pAudioClient->lpVtbl->GetService (s->pAudioClient, &XIID_IAudioClock, (void**)&s->pAudioClock); + hr = s->pAudioClient->GetService (IAudioClock, (void**)&s->pAudioClock); if (FAILED (hr)) { - write_log (L"WASAPI: GetService(IID_IAudioClock) %08X\n", hr); + write_log (L"WASAPI: GetService(IAudioClock) %08X\n", hr); } else { - hr = s->pAudioClock->lpVtbl->GetFrequency (s->pAudioClock, &s->wasapiclock); + hr = s->pAudioClock->GetFrequency (&s->wasapiclock); if (FAILED (hr)) { write_log (L"WASAPI: GetFrequency() %08X\n", hr); } @@ -1089,7 +1081,7 @@ static int open_audio_ds (struct sound_data *sd, int index) if (pdsb == NULL) goto error; - hr = IDirectSound_QueryInterface (pdsb, &IID_IDirectSoundBuffer8, (LPVOID*)&s->lpDSBsecondary); + hr = pdsb->QueryInterface (IID_IDirectSoundBuffer8, (LPVOID*)&s->lpDSBsecondary); if (FAILED (hr)) { write_log (L"DSSOUND: Secondary QueryInterface() failure: %s\n", DXError (hr)); goto error; @@ -1107,7 +1099,7 @@ error: int open_sound_device (struct sound_data *sd, int index, int exclusive, int bufsize, int freq, int channels) { int ret = 0; - struct sound_dp *sdp = xcalloc (sizeof (struct sound_dp), 1); + struct sound_dp *sdp = xcalloc (struct sound_dp, 1); sd->data = sdp; sd->sndbufsize = bufsize; sd->freq = freq; @@ -1578,7 +1570,8 @@ static void finish_sound_buffer_wasapi (struct sound_data *sd, uae_u16 *sndbuffe BYTE *pData; DWORD v; double skipmode; - int numFramesPadding, avail; + UINT32 numFramesPadding; + int avail; int stuck = 2000; int oldpadding = 0; @@ -1592,7 +1585,7 @@ static void finish_sound_buffer_wasapi (struct sound_data *sd, uae_u16 *sndbuffe } for (;;) { - hr = s->pAudioClient->lpVtbl->GetCurrentPadding (s->pAudioClient, &numFramesPadding); + hr = s->pAudioClient->GetCurrentPadding (&numFramesPadding); if (FAILED (hr)) { write_log (L"WASAPI: GetCurrentPadding() %08X\n", hr); return; @@ -1618,10 +1611,10 @@ static void finish_sound_buffer_wasapi (struct sound_data *sd, uae_u16 *sndbuffe skipmode = sync_sound (gui_data.sndbuf / 70.0); sound_setadjust (skipmode); } - hr = s->pRenderClient->lpVtbl->GetBuffer (s->pRenderClient, s->sndbufframes, &pData); + hr = s->pRenderClient->GetBuffer (s->sndbufframes, &pData); if (SUCCEEDED (hr)) { memcpy (pData, sndbuffer, sd->sndbufsize); - s->pRenderClient->lpVtbl->ReleaseBuffer (s->pRenderClient, s->sndbufframes, 0); + s->pRenderClient->ReleaseBuffer (s->sndbufframes, 0); } } @@ -1641,14 +1634,14 @@ static void finish_sound_buffer_ds (struct sound_data *sd, uae_u16 *sndbuffer) return; if (sd->waiting_for_buffer == 1) { - hr = IDirectSoundBuffer_Play (s->lpDSBsecondary, 0, 0, DSBPLAY_LOOPING); + hr = s->lpDSBsecondary->Play (0, 0, DSBPLAY_LOOPING); if (FAILED (hr)) { write_log (L"DSSOUND: Play failed: %s\n", DXError (hr)); restore_ds (sd, DSERR_BUFFERLOST); sd->waiting_for_buffer = 0; return; } - hr = IDirectSoundBuffer_SetCurrentPosition (s->lpDSBsecondary, 0); + hr = s->lpDSBsecondary->SetCurrentPosition (0); if (FAILED (hr)) { write_log (L"DSSOUND: 1st SetCurrentPosition failed: %s\n", DXError (hr)); restore_ds (sd, DSERR_BUFFERLOST); @@ -1658,7 +1651,7 @@ static void finish_sound_buffer_ds (struct sound_data *sd, uae_u16 *sndbuffer) /* there are crappy drivers that return PLAYCURSOR = WRITECURSOR = 0 without this.. */ counter = 5000; for (;;) { - hr = IDirectSoundBuffer_GetCurrentPosition (s->lpDSBsecondary, &playpos, &s->safedist); + hr = s->lpDSBsecondary->GetCurrentPosition (&playpos, &s->safedist); if (playpos > 0) break; sleep_millis (1); @@ -1696,7 +1689,7 @@ static void finish_sound_buffer_ds (struct sound_data *sd, uae_u16 *sndbuffer) } counter = 5000; - hr = IDirectSoundBuffer_GetStatus (s->lpDSBsecondary, &status); + hr = s->lpDSBsecondary->GetStatus (&status); if (FAILED (hr)) { write_log (L"DSSOUND: GetStatus() failed: %s\n", DXError (hr)); restore_ds (sd, DSERR_BUFFERLOST); @@ -1713,7 +1706,7 @@ static void finish_sound_buffer_ds (struct sound_data *sd, uae_u16 *sndbuffer) return; } for (;;) { - hr = IDirectSoundBuffer_GetCurrentPosition (s->lpDSBsecondary, &playpos, &safepos); + hr = s->lpDSBsecondary->GetCurrentPosition (&playpos, &safepos); if (FAILED (hr)) { restore_ds (sd, hr); write_log (L"DSSOUND: GetCurrentPosition failed: %s\n", DXError (hr)); @@ -1769,7 +1762,7 @@ static void finish_sound_buffer_ds (struct sound_data *sd, uae_u16 *sndbuffer) break; } - hr = IDirectSoundBuffer_Lock (s->lpDSBsecondary, s->writepos, sd->sndbufsize, &b1, &s1, &b2, &s2, 0); + hr = s->lpDSBsecondary->Lock (s->writepos, sd->sndbufsize, &b1, &s1, &b2, &s2, 0); if (restore_ds (sd, hr)) return; if (FAILED (hr)) { @@ -1779,7 +1772,7 @@ static void finish_sound_buffer_ds (struct sound_data *sd, uae_u16 *sndbuffer) memcpy (b1, sndbuffer, s1); if (b2) memcpy (b2, (uae_u8*)sndbuffer + s1, s2); - IDirectSoundBuffer_Unlock (s->lpDSBsecondary, b1, s1, b2, s2); + s->lpDSBsecondary->Unlock (b1, s1, b2, s2); if (sd == sdp) { double vdiff, m, skipmode; @@ -1874,7 +1867,7 @@ void finish_sound_buffer (void) static BOOL CALLBACK DSEnumProc (LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext) { - struct sound_device *sd = lpContext; + struct sound_device *sd = (struct sound_device*)lpContext; int i; for (i = 0; i < MAX_SOUND_DEVICES; i++) { @@ -1907,35 +1900,34 @@ static void wasapi_enum (struct sound_device *sd) if (cnt >= MAX_SOUND_DEVICES) return; - hr = CoCreateInstance (&XCLSID_MMDeviceEnumerator, NULL, - CLSCTX_ALL, &XIID_IMMDeviceEnumerator, - (void**)&enumerator); + hr = CoCreateInstance (__uuidof(MMDeviceEnumerator), NULL, + CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&enumerator); if (SUCCEEDED (hr)) { - hr = enumerator->lpVtbl->EnumAudioEndpoints (enumerator, eRender, DEVICE_STATE_ACTIVE, &col); + hr = enumerator->EnumAudioEndpoints (eRender, DEVICE_STATE_ACTIVE, &col); if (SUCCEEDED (hr)) { UINT num; - hr = col->lpVtbl->GetCount (col, &num); + hr = col->GetCount (&num); if (SUCCEEDED (hr)) { for (i = 0; i < num && cnt < MAX_SOUND_DEVICES; i++) { IMMDevice *dev; LPWSTR devid = NULL; LPWSTR devname = NULL; - hr = col->lpVtbl->Item (col, i, &dev); + hr = col->Item (i, &dev); if (SUCCEEDED (hr)) { IPropertyStore *prop; - dev->lpVtbl->GetId (dev, &devid); - hr = dev->lpVtbl->OpenPropertyStore (dev, STGM_READ, &prop); + dev->GetId (&devid); + hr = dev->OpenPropertyStore (STGM_READ, &prop); if (SUCCEEDED (hr)) { PROPVARIANT pv; PropVariantInit (&pv); - hr = prop->lpVtbl->GetValue (prop, &PKEY_Device_FriendlyName, &pv); + hr = prop->GetValue (PKEY_Device_FriendlyName, &pv); if (SUCCEEDED (hr)) { devname = my_strdup (pv.pwszVal); } PropVariantClear (&pv); - prop->lpVtbl->Release (prop); + prop->Release (); } - dev->lpVtbl->Release (dev); + dev->Release (); } if (devid && devname) { TCHAR tmp[MAX_DPATH]; @@ -1961,9 +1953,9 @@ static void wasapi_enum (struct sound_device *sd) CoTaskMemFree (devid); } } - col->lpVtbl->Release (col); + col->Release (); } - enumerator->lpVtbl->Release (enumerator); + enumerator->Release (); } } @@ -2166,12 +2158,7 @@ int enumerate_sound_devices (void) /* Based on http://blogs.msdn.com/larryosterman/archive/2007/03/06/how-do-i-change-the-master-volume-in-windows-vista.aspx - */ -const static GUID XIID_MMDeviceEnumerator = {0xBCDE0395,0xE52F,0x467C, -{0x8E,0x3D,0xC4,0x57,0x92,0x91,0x69,0x2E}}; -const static GUID XIID_IAudioEndpointVolume = {0x5CDF2C82, 0x841E,0x4546, -{0x97,0x22,0x0C,0xF7,0x40,0x78,0x22,0x9A}}; static int setget_master_volume_vista (int setvolume, int *volume, int *mute) { @@ -2184,33 +2171,33 @@ static int setget_master_volume_vista (int setvolume, int *volume, int *mute) hr = CoInitialize (NULL); if (FAILED (hr)) return 0; - hr = CoCreateInstance (&XIID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &XIID_IMMDeviceEnumerator, (LPVOID *)&deviceEnumerator); + hr = CoCreateInstance (__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER, __uuidof(IMMDeviceEnumerator), (LPVOID *)&deviceEnumerator); if (FAILED (hr)) return 0; - hr = deviceEnumerator->lpVtbl->GetDefaultAudioEndpoint (deviceEnumerator, eRender, eConsole, &defaultDevice); + hr = deviceEnumerator->GetDefaultAudioEndpoint (eRender, eConsole, &defaultDevice); if (SUCCEEDED (hr)) { - hr = defaultDevice->lpVtbl->Activate (defaultDevice, &XIID_IAudioEndpointVolume, CLSCTX_INPROC_SERVER, NULL, (LPVOID *)&endpointVolume); + hr = defaultDevice->Activate (__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (LPVOID *)&endpointVolume); if (SUCCEEDED (hr)) { if (setvolume) { - if (SUCCEEDED (endpointVolume->lpVtbl->SetMasterVolumeLevelScalar (endpointVolume, (float)(*volume) / (float)65535.0, NULL))) + if (SUCCEEDED (endpointVolume->SetMasterVolumeLevelScalar ((float)(*volume) / (float)65535.0, NULL))) ok++; - if (SUCCEEDED (endpointVolume->lpVtbl->SetMute (endpointVolume, *mute, NULL))) + if (SUCCEEDED (endpointVolume->SetMute (*mute, NULL))) ok++; } else { float vol; - if (SUCCEEDED (endpointVolume->lpVtbl->GetMasterVolumeLevelScalar (endpointVolume, &vol))) { + if (SUCCEEDED (endpointVolume->GetMasterVolumeLevelScalar (&vol))) { ok++; *volume = vol * 65535.0; } - if (SUCCEEDED (endpointVolume->lpVtbl->GetMute (endpointVolume, mute))) { + if (SUCCEEDED (endpointVolume->GetMute (mute))) { ok++; } } - endpointVolume->lpVtbl->Release (endpointVolume); + endpointVolume->Release (); } - defaultDevice->lpVtbl->Release (defaultDevice); + defaultDevice->Release (); } - deviceEnumerator->lpVtbl->Release (deviceEnumerator); + deviceEnumerator->Release (); CoUninitialize (); return ok == 2; } diff --git a/od-win32/sounddep/sound.h b/od-win32/sounddep/sound.h index 68ad9a6b..1e6c97bc 100644 --- a/od-win32/sounddep/sound.h +++ b/od-win32/sounddep/sound.h @@ -28,6 +28,8 @@ extern void sound_volume (int); extern void set_volume (int, int); extern void master_sound_volume (int); +struct sound_dp; + struct sound_data { int waiting_for_buffer; @@ -39,7 +41,7 @@ struct sound_data int freq; int samplesize; int sndbufsize; - void *data; + struct sound_dp *data; }; diff --git a/od-win32/srcrelease.cmd b/od-win32/srcrelease.cmd index 39810669..a32dc93f 100644 --- a/od-win32/srcrelease.cmd +++ b/od-win32/srcrelease.cmd @@ -6,31 +6,31 @@ copy d:\amiga\text\winuaechangelog.txt c:\projects\winuae_bak\bak\od-win32 copy d:\amiga\amiga\filesys.asm c:\projects\winuae_bak\bak cd bak -del *.obj *.ilk *.exe *.pdb *.pch *.idb /s +del *.obj *.ilk *.exe *.pdb *.pch *.idb *.ncb *.sln *.suo *.ncb *.sdf /s -del cpudefs.c +del cpudefs.cpp del blit.h -del blitfunc.c +del blitfunc.cpp del blitfunc.h -del blittable.c +del blittable.cpp del cputbl.h -del cpustbl.c -del compemu.c +del cpustbl.cpp +del compemu.cpp del comptbl.h -del compstbl.c -del cpuemu_0.c -del cpuemu_11.c -del cpuemu_12.c -del cpuemu_21.c -del cpuemu_31.c -del linetoscr.c +del compstbl.cpp +del cpuemu_0.cpp +del cpuemu_11.cpp +del cpuemu_12.cpp +del cpuemu_20.cpp +del cpuemu_31.cpp +del linetoscr.cpp cd jit -del compemu.c +del compemu.cpp del compstbl.h -del compstbl.c +del compstbl.cpp cd .. cd od-win32 @@ -82,27 +82,18 @@ rm -rf fullrelease cd .. cd winuae_msvc -rm -f winuae_msvc.ncb rm -rf debug rm -rf release rm -rf fullrelease cd .. cd winuae_msvc10 -rm -f winuae_msvc.ncb -rm -f winuae_msvc.sdf rm -rf debug rm -rf release rm -rf fullrelease rm -rf ipch cd .. -cd soundcheck -rm -rf debug -rm -rf release -rm -rf fullrelease -cd .. - cd singlefilehelper rm -rf debug rm -rf release @@ -140,7 +131,7 @@ zip -9 -r winuaesrc * copy winuaesrc.zip d:\amiga\winuaepackets\winuaesrc%1.zip move winuaesrc.zip d:\amiga cd c:\projects\winuae\src\od-win32 -zip -9 winuaedebug%1 winuae_msvc\release\winuae.pdb winuae_msvc\fullrelease\winuae.pdb +zip -9 winuaedebug%1 winuae_msvc\release\winuae.pdb winuae_msvc\fullrelease\winuae.pdb winuae_msvc10\release\winuae.pdb winuae_msvc10\fullrelease\winuae.pdb move winuaedebug%1.zip d:\amiga\winuaepackets\ -copy winuae_msvc\fullrelease\winuae.pdb d:\amiga\dump +copy winuae_msvc10\fullrelease\winuae.pdb d:\amiga\dump copy d:\amiga\winuae.exe d:\amiga\dump diff --git a/od-win32/support.c b/od-win32/support.cpp similarity index 100% rename from od-win32/support.c rename to od-win32/support.cpp diff --git a/od-win32/tun.c b/od-win32/tun.cpp similarity index 100% rename from od-win32/tun.c rename to od-win32/tun.cpp diff --git a/od-win32/uaeunp/uaeunp.vcproj b/od-win32/uaeunp/uaeunp.vcproj index b60a1059..9cca58aa 100644 --- a/od-win32/uaeunp/uaeunp.vcproj +++ b/od-win32/uaeunp/uaeunp.vcproj @@ -178,31 +178,31 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > @@ -260,55 +260,55 @@ Name="7z" > @@ -316,47 +316,47 @@ Name="lha" > @@ -364,7 +364,7 @@ Name="zip" > @@ -372,7 +372,7 @@ Name="lzx" > @@ -384,7 +384,7 @@ Name="wrp" > @@ -393,23 +393,23 @@ Name="win32" > diff --git a/od-win32/uaeunp/uaeunp.vcxproj b/od-win32/uaeunp/uaeunp.vcxproj index b45efcfb..e9554e88 100644 --- a/od-win32/uaeunp/uaeunp.vcxproj +++ b/od-win32/uaeunp/uaeunp.vcxproj @@ -48,7 +48,7 @@ Disabled ..\..\include;..\..;..\;..\resources;..\osdep;..\sounddep;..\..\prowizard\include;..\tun;%(AdditionalIncludeDirectories) - WINVER=0x0500;_DEBUG;WIN32_IE=0x0700;WIN32;CINTERFACE;COBJMACROS;_CRT_SECURE_NO_WARNINGS;_CONSOLE;%(PreprocessorDefinitions) + WINVER=0x0500;_DEBUG;WIN32_IE=0x0700;WIN32;_CRT_SECURE_NO_WARNINGS;_CONSOLE;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -56,6 +56,7 @@ Level3 EditAndContinue + Default zlibstat.lib;wininet.lib;%(AdditionalDependencies) @@ -90,56 +91,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/od-win32/uaeunp/uaeunp.vcxproj.filters b/od-win32/uaeunp/uaeunp.vcxproj.filters index bec54a4a..358d6fe0 100644 --- a/od-win32/uaeunp/uaeunp.vcxproj.filters +++ b/od-win32/uaeunp/uaeunp.vcxproj.filters @@ -42,154 +42,154 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\dms - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\7z - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\lha - + Source Files\decompressors\zip - + Source Files\decompressors\lzx - + Source Files\decompressors\wrp - + Source Files\win32 - + Source Files\win32 - + Source Files\win32 - + Source Files\win32 - + Source Files\win32 diff --git a/od-win32/uaeunp_win32.c b/od-win32/uaeunp_win32.cpp similarity index 89% rename from od-win32/uaeunp_win32.c rename to od-win32/uaeunp_win32.cpp index 1ac23c8a..1bd2961c 100644 --- a/od-win32/uaeunp_win32.c +++ b/od-win32/uaeunp_win32.cpp @@ -29,7 +29,7 @@ HMODULE WIN32_LoadLibrary (const TCHAR *name) #endif int round; - newname = xmalloc ((_tcslen (name) + 1 + 10) * sizeof (TCHAR)); + newname = xmalloc (TCHAR, _tcslen (name) + 1 + 10); if (!newname) return NULL; for (round = 0; round < 4; round++) { @@ -57,7 +57,7 @@ HMODULE WIN32_LoadLibrary (const TCHAR *name) break; } #endif - s = xmalloc ((_tcslen (start_path_exe) + _tcslen (WIN32_PLUGINDIR) + _tcslen (newname) + 1) * sizeof (TCHAR)); + s = xmalloc (TCHAR, _tcslen (start_path_exe) + _tcslen (WIN32_PLUGINDIR) + _tcslen (newname) + 1); if (s) { _stprintf (s, L"%s%s%s", start_path_exe, WIN32_PLUGINDIR, newname); m = LoadLibrary (s); diff --git a/od-win32/unicode.c b/od-win32/unicode.cpp similarity index 96% rename from od-win32/unicode.c rename to od-win32/unicode.cpp index 7f716796..4228484f 100644 --- a/od-win32/unicode.c +++ b/od-win32/unicode.cpp @@ -47,7 +47,7 @@ char *uutf8 (const WCHAR *s) err (__FUNCTION__, s, NULL, CP_UTF8); return strdup (""); } - d = xmalloc (len + 1); + d = xmalloc (char, len + 1); WideCharToMultiByte (CP_UTF8, 0, s, -1, d, len, 0, FALSE); return d; } @@ -61,9 +61,9 @@ WCHAR *utf8u (const char *s) len = MultiByteToWideChar (CP_UTF8, 0, s, -1, NULL, 0); if (!len) { err (__FUNCTION__, NULL, s, CP_UTF8); - return xcalloc (2, 1); + return xcalloc (WCHAR, 1); } - d = xmalloc ((len + 1) * sizeof (WCHAR)); + d = xmalloc (WCHAR, len + 1); MultiByteToWideChar (CP_UTF8, 0, s, -1, d, len); return d; } @@ -80,7 +80,7 @@ static char *ua_2 (const WCHAR *s, UINT cp) err (__FUNCTION__, s, NULL, cp); return strdup (""); } - d = xmalloc (len + 1); + d = xmalloc (char, len + 1); WideCharToMultiByte (cp, 0, s, -1, d, len, 0, FALSE); return d; } @@ -104,9 +104,9 @@ static WCHAR *au_2 (const char *s, UINT cp) len = MultiByteToWideChar (cp, 0, s, -1, NULL, 0); if (!len) { err (__FUNCTION__, NULL, s, cp); - return xcalloc (2, 1); + return xcalloc (WCHAR, 1); } - d = xmalloc ((len + 1) * sizeof (WCHAR)); + d = xmalloc (WCHAR, len + 1); MultiByteToWideChar (cp, 0, s, -1, d, len); return d; } @@ -166,7 +166,7 @@ char *ua_fs (const WCHAR *s, int defchar) err (__FUNCTION__, s, NULL, fscodepage); return strdup (""); } - d = xmalloc (len + 1); + d = xmalloc (char, len + 1); dc = FALSE; WideCharToMultiByte (fscodepage, DWFLAGS | WC_NO_BEST_FIT_CHARS, s, -1, d, len, &def, &dc); if (dc) { @@ -235,7 +235,7 @@ WCHAR *au_fs (const char *s) WCHAR *d; len = strlen (s); - d = xmalloc ((len + 1) * sizeof (WCHAR)); + d = xmalloc (WCHAR, len + 1); for (i = 0; i < len; i++) d[i] = aufstable[(uae_u8)s[i]]; d[len] = 0; diff --git a/od-win32/win32.c b/od-win32/win32.cpp similarity index 98% rename from od-win32/win32.c rename to od-win32/win32.cpp index 68ffccbc..bf25f705 100644 --- a/od-win32/win32.c +++ b/od-win32/win32.cpp @@ -99,7 +99,7 @@ extern int console_logging; OSVERSIONINFO osVersion; static SYSTEM_INFO SystemInfo; static int logging_started; -static DWORD minidumpmode = MiniDumpNormal; +static MINIDUMP_TYPE minidumpmode = MiniDumpNormal; static int doquit; static int console_started; void *globalipc, *serialipc; @@ -164,7 +164,7 @@ TCHAR start_path_new1[MAX_DPATH]; /* AF2005 */ TCHAR start_path_new2[MAX_DPATH]; /* AMIGAFOREVERDATA */ TCHAR help_file[MAX_DPATH]; int af_path_2005, af_path_old; -DWORD quickstart = 1, configurationcache = 1; +int quickstart = 1, configurationcache = 1; static int multi_display = 1; static TCHAR *inipath = NULL; @@ -201,7 +201,7 @@ static int init_mmtimer (void) int i; mm_timerres = 0; - if (timeGetDevCaps (&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) + if (timeGetDevCaps (&tc, sizeof (TIMECAPS)) != TIMERR_NOERROR) return 0; mm_timerres = min (max (tc.wPeriodMin, 1), tc.wPeriodMax); sleep_resolution = 1000 / mm_timerres; @@ -224,7 +224,7 @@ void sleep_millis (int ms) if (timehandlecounter >= MAX_TIMEHANDLES) timehandlecounter = 0; LeaveCriticalSection (&cs_time); - TimerEvent = timeSetEvent (ms, 0, timehandle[cnt], 0, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); + TimerEvent = timeSetEvent (ms, 0, (LPTIMECALLBACK)timehandle[cnt], 0, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); WaitForSingleObject (timehandle[cnt], ms); ResetEvent (timehandle[cnt]); timeKillEvent (TimerEvent); @@ -1838,7 +1838,7 @@ HMODULE language_load (WORD language) if (result) { dwFileVersionInfoSize = GetFileVersionInfoSize (dllbuf, &dwVersionHandle); if (dwFileVersionInfoSize) { - if (lpFileVersionData = xcalloc (1, dwFileVersionInfoSize)) { + if (lpFileVersionData = xcalloc (uae_u8, dwFileVersionInfoSize)) { if (GetFileVersionInfo (dllbuf, dwVersionHandle, dwFileVersionInfoSize, lpFileVersionData)) { VS_FIXEDFILEINFO *vsFileInfo = NULL; UINT uLen; @@ -2045,7 +2045,7 @@ uae_u8 *save_log (int bootlog, int *len) if (size > 30000) size = 30000; if (size > 0) { - dst = xcalloc (1, size + 1); + dst = xcalloc (uae_u8, size + 1); if (dst) fread (dst, 1, size, f); fclose (f); @@ -2105,7 +2105,7 @@ uae_u8 *target_load_keyfile (struct uae_prefs *p, TCHAR *path, int *sizep, TCHAR //write_log (L"size: %d\n", size); if (size > 0) { int gotsize; - keybuf = xmalloc (size); + keybuf = xmalloc (uae_u8, size); gotsize = pfnGetKey (keybuf, size); //write_log (L"gotsize: %d\n", gotsize); if (gotsize != size) { @@ -2120,9 +2120,9 @@ uae_u8 *target_load_keyfile (struct uae_prefs *p, TCHAR *path, int *sizep, TCHAR } -extern TCHAR *get_aspi_path(int); +extern const TCHAR *get_aspi_path (int); -static get_aspi (int old) +static int get_aspi (int old) { if ((old == UAESCSI_SPTI || old == UAESCSI_SPTISCAN) && os_winnt_admin) return old; @@ -2370,7 +2370,7 @@ static TCHAR **parseargstring (TCHAR *s) return NULL; wparse_cmdline (s, NULL, NULL, &numa, &numc); numa++; - p = xcalloc (numa * sizeof (TCHAR*) + numc * sizeof (TCHAR), 1); + p = (TCHAR**)xcalloc (uae_u8, numa * sizeof (TCHAR*) + numc * sizeof (TCHAR)); wparse_cmdline (s, (wchar_t **)p, (wchar_t *)(((char *)p) + numa * sizeof(wchar_t *)), &numa, &numc); if (numa > MAX_ARGUMENTS) p[MAX_ARGUMENTS] = NULL; @@ -2399,7 +2399,7 @@ static void shellexecute (TCHAR *command) i++; } exec = NULL; - cmd = xcalloc (len, sizeof (TCHAR)); + cmd = xcalloc (TCHAR, len); for (k = j; k < i; k++) { int quote = 0; if (_tcslen (cmd) > 0) @@ -2415,7 +2415,7 @@ static void shellexecute (TCHAR *command) int size; size = GetEnvironmentVariable (L"ComSpec", NULL, 0); if (size > 0) { - exec = xcalloc (size + 1, sizeof (TCHAR)); + exec = xcalloc (TCHAR, size + 1); GetEnvironmentVariable (L"ComSpec", exec, size); } cmd[0] = 0; @@ -3357,7 +3357,7 @@ static void WIN32_HandleRegistryStuff (void) RGBFTYPE colortype = RGBFB_NONE; DWORD dwType = REG_DWORD; DWORD dwDisplayInfoSize = sizeof (colortype); - DWORD size; + int size; TCHAR path[MAX_DPATH] = L""; TCHAR version[100]; @@ -3688,7 +3688,7 @@ static void getstartpaths (void) xstart_path_uae[0] = xstart_path_old[0] = xstart_path_new1[0] = xstart_path_new2[0] = 0; key = regcreatetree (NULL, NULL); if (key) { - DWORD size = sizeof (prevpath) / sizeof (TCHAR); + int size = sizeof (prevpath) / sizeof (TCHAR); if (!regquerystr (key, L"PathMode", prevpath, &size)) prevpath[0] = 0; regclosetree (key); @@ -4056,7 +4056,7 @@ static int parseargs (const TCHAR *arg, const TCHAR *np, const TCHAR *np2) return 2; } if (!_tcscmp (arg, L"-minidumpmode")) { - minidumpmode = getval (np); + minidumpmode = (MINIDUMP_TYPE)getval (np); return 2; } if (!_tcscmp (arg, L"-jitevent")) { @@ -4195,7 +4195,7 @@ static TCHAR **WIN32_InitRegistry (TCHAR **argv) { DWORD disposition; TCHAR tmp[MAX_DPATH]; - DWORD size = sizeof tmp / sizeof (TCHAR); + int size = sizeof tmp / sizeof (TCHAR); reginitializeinit (inipath); hWinUAEKey = NULL; @@ -4257,7 +4257,7 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR hMutex = CreateMutex (NULL, FALSE, L"WinUAE Instantiated"); // To tell the installer we're running - argv = xcalloc (sizeof (TCHAR*), MAX_ARGUMENTS); + argv = xcalloc (TCHAR*, MAX_ARGUMENTS); argv3 = NULL; argc = process_arg (lpCmdLine, argv, &argv3); if (doquit) @@ -4408,7 +4408,7 @@ int driveclick_loadresource (struct drvsample *sp, int drivetype) if (res != 0) { HANDLE h = LoadResource (NULL, res); int len = SizeofResource (NULL, res); - uae_u8 *p = LockResource (h); + uae_u8 *p = (uae_u8*)LockResource (h); s->p = decodewav (p, &len); s->len = len; } else { @@ -4450,7 +4450,7 @@ static void savedump (MINIDUMPWRITEDUMP dump, HANDLE f, struct _EXCEPTION_POINTE MINIDUMP_EXCEPTION_INFORMATION exinfo; MINIDUMP_USER_STREAM_INFORMATION musi, *musip; MINIDUMP_USER_STREAM mus[2], *musp; - uae_char *log; + uae_u8 *log; int loglen; musip = NULL; @@ -4736,7 +4736,7 @@ HMODULE WIN32_LoadLibrary_2 (const TCHAR *name, int expand) #endif int round; - newname = xmalloc ((_tcslen (name) + 1 + 10) * sizeof (TCHAR)); + newname = xmalloc (TCHAR, _tcslen (name) + 1 + 10); if (!newname) return NULL; for (round = 0; round < 4; round++) { @@ -4754,8 +4754,8 @@ HMODULE WIN32_LoadLibrary_2 (const TCHAR *name, int expand) break; case 1: p = _tcschr (newname, '.'); - _tcscpy(p, L"_64"); - _tcscat(p, _tcschr (name, '.')); + _tcscpy (p, L"_64"); + _tcscat (p, _tcschr (name, '.')); break; case 2: p = _tcschr (newname, '.'); @@ -4764,18 +4764,18 @@ HMODULE WIN32_LoadLibrary_2 (const TCHAR *name, int expand) break; } #endif - s = xmalloc ((_tcslen (start_path_exe) + _tcslen (WIN32_PLUGINDIR) + _tcslen (newname) + 1) * sizeof (TCHAR)); + s = xmalloc (TCHAR, _tcslen (start_path_exe) + _tcslen (WIN32_PLUGINDIR) + _tcslen (newname) + 1); if (s) { _stprintf (s, L"%s%s%s", start_path_exe, WIN32_PLUGINDIR, newname); m = LoadLibrary (s); - LLError(m, s); + LLError (m, s); if (m) { xfree (s); goto end; } _stprintf (s, L"%s%s", start_path_exe, newname); m = LoadLibrary (s); - LLError(m ,s); + LLError (m ,s); if (m) { xfree (s); goto end; @@ -4813,7 +4813,7 @@ int isdllversion (const TCHAR *name, int version, int revision, int subver, int dwFileVersionInfoSize = GetFileVersionInfoSize (name, &dwVersionHandle); if (dwFileVersionInfoSize) { - if (lpFileVersionData = xcalloc (1, dwFileVersionInfoSize)) { + if (lpFileVersionData = xcalloc (uae_u8, dwFileVersionInfoSize)) { if (GetFileVersionInfo (name, dwVersionHandle, dwFileVersionInfoSize, lpFileVersionData)) { VS_FIXEDFILEINFO *vsFileInfo = NULL; UINT uLen; @@ -4871,9 +4871,9 @@ void target_addtorecent (const TCHAR *name, int t) if (!pSHCreateItemFromParsingName) return; shard.pszAppID = WINUAEAPPNAME; - if (SUCCEEDED (pSHCreateItemFromParsingName (tmp, NULL, &IID_IShellItem, &shard.psi))) { + if (SUCCEEDED (pSHCreateItemFromParsingName (tmp, NULL, IID_IShellItem, (void**)&shard.psi))) { SHAddToRecentDocs (SHARD_APPIDINFO, &shard); - IShellItem_Release (shard.psi); + shard.psi->Release(); } } else { SHAddToRecentDocs (SHARD_PATH, tmp); diff --git a/od-win32/win32.h b/od-win32/win32.h index 0b20ff39..35617922 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -18,8 +18,8 @@ #define WINUAEPUBLICBETA 1 #define LANG_DLL 1 -#define WINUAEBETA L"10" -#define WINUAEDATE MAKEBD(2010, 2, 10) +#define WINUAEBETA L"11" +#define WINUAEDATE MAKEBD(2010, 2, 13) #define WINUAEEXTRA L"" #define WINUAEREV L"" @@ -65,7 +65,6 @@ extern void resumepaused (int priority); extern void setpaused (int priority); void finishjob (void); -void updatedisplayarea (void); void init_colors (void); extern int pause_emulation; @@ -78,7 +77,7 @@ extern int os_winnt_admin, os_64bit, os_vista, os_winxp, os_win7; extern OSVERSIONINFO osVersion; extern int paraport_mask; extern int gui_active; -extern DWORD quickstart, configurationcache; +extern int quickstart, configurationcache; extern HKEY hWinUAEKey; extern int screen_is_picasso, scalepicasso; diff --git a/od-win32/win32_decompress.c b/od-win32/win32_decompress.cpp similarity index 100% rename from od-win32/win32_decompress.c rename to od-win32/win32_decompress.cpp diff --git a/od-win32/win32_filesys.c b/od-win32/win32_filesys.cpp similarity index 99% rename from od-win32/win32_filesys.c rename to od-win32/win32_filesys.cpp index 6b0e9d87..a259c1e8 100644 --- a/od-win32/win32_filesys.c +++ b/od-win32/win32_filesys.cpp @@ -99,7 +99,7 @@ static int getidfromhandle (HANDLE h) VOLUME_DISK_EXTENTS *vde; outsize = sizeof (VOLUME_DISK_EXTENTS) + sizeof (DISK_EXTENT) * 32; - vde = xmalloc (outsize); + vde = (VOLUME_DISK_EXTENTS*)xmalloc (uae_u8, outsize); if (DeviceIoControl (h, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, vde, outsize, &written, NULL)) { if (vde->NumberOfDiskExtents > 0) drvnum = vde->Extents[0].DiskNumber; diff --git a/od-win32/win32_nogui.c b/od-win32/win32_nogui.cpp similarity index 100% rename from od-win32/win32_nogui.c rename to od-win32/win32_nogui.cpp diff --git a/od-win32/win32_scale2x.c b/od-win32/win32_scale2x.cpp similarity index 99% rename from od-win32/win32_scale2x.c rename to od-win32/win32_scale2x.cpp index dcf4e5b9..ad8c16dd 100644 --- a/od-win32/win32_scale2x.c +++ b/od-win32/win32_scale2x.cpp @@ -528,8 +528,8 @@ void S2X_init (int dw, int dh, int aw, int ah, int mult, int ad, int dd) if (usedfilter->type == UAE_FILTER_HQ) { int w = amiga_width > dst_width ? amiga_width : dst_width; int h = amiga_height > dst_height ? amiga_height : dst_height; - tempsurf2 = xmalloc (w * h * (amiga_depth / 8) * ((scale + 1) / 2)); - tempsurf3 = xmalloc (w * h *(dst_depth / 8) * 4 * scale); + tempsurf2 = xmalloc (uae_u8, w * h * (amiga_depth / 8) * ((scale + 1) / 2)); + tempsurf3 = xmalloc (uae_u8, w * h *(dst_depth / 8) * 4 * scale); if (!d3d) tempsurf = allocsystemsurface (temp_width, temp_height); } else { @@ -548,7 +548,7 @@ void S2X_render (void) int ok = 0; RECT sr, dr, zr; DDSURFACEDESC2 desc; - DWORD pitch; + int pitch; uae_u8 *surfstart; aw = amiga_width; diff --git a/od-win32/win32_uaenet.c b/od-win32/win32_uaenet.cpp similarity index 91% rename from od-win32/win32_uaenet.c rename to od-win32/win32_uaenet.cpp index 0354ac9d..d021abbc 100644 --- a/od-win32/win32_uaenet.c +++ b/od-win32/win32_uaenet.cpp @@ -144,7 +144,7 @@ static void *uaenet_trap_thread (void *arg) static void *uaenet_trap_threadr (void *arg) { - struct uaenetdatawin32 *sd = arg; + struct uaenetdatawin32 *sd = (struct uaenetdatawin32*)arg; struct pcap_pkthdr *header; const u_char *pkt_data; @@ -156,7 +156,7 @@ static void *uaenet_trap_threadr (void *arg) r = pcap_next_ex (sd->fp, &header, &pkt_data); if (r == 1) { uae_sem_wait (&sd->change_sem); - sd->gotfunc (sd->user, pkt_data, header->len); + sd->gotfunc ((struct devstruct*)sd->user, pkt_data, header->len); uae_sem_post (&sd->change_sem); } if (r < 0) { @@ -171,7 +171,7 @@ static void *uaenet_trap_threadr (void *arg) static void *uaenet_trap_threadw (void *arg) { - struct uaenetdatawin32 *sd = arg; + struct uaenetdatawin32 *sd = (struct uaenetdatawin32*)arg; uae_set_thread_priority (NULL, 1); sd->threadactivew = 1; @@ -180,7 +180,7 @@ static void *uaenet_trap_threadw (void *arg) int donotwait = 0; int towrite = sd->mtu; uae_sem_wait (&sd->change_sem); - if (sd->getfunc (sd->user, sd->writebuffer, &towrite)) { + if (sd->getfunc ((struct devstruct*)sd->user, sd->writebuffer, &towrite)) { pcap_sendpacket (sd->fp, sd->writebuffer, towrite); donotwait = 1; } @@ -193,15 +193,17 @@ static void *uaenet_trap_threadw (void *arg) return 0; } -void uaenet_trigger (struct uaenetdatawin32 *sd) +void uaenet_trigger (void *vsd) { + struct uaenetdatawin32 *sd = (struct uaenetdatawin32*)vsd; if (!sd) return; SetEvent (sd->evttw); } -int uaenet_open (struct uaenetdatawin32 *sd, struct netdriverdata *tc, void *user, uaenet_gotfunc *gotfunc, uaenet_getfunc *getfunc, int promiscuous) +int uaenet_open (void *vsd, struct netdriverdata *tc, void *user, uaenet_gotfunc *gotfunc, uaenet_getfunc *getfunc, int promiscuous) { + struct uaenetdatawin32 *sd = (struct uaenetdatawin32*)vsd; char *s; s = ua (tc->name); @@ -220,8 +222,8 @@ int uaenet_open (struct uaenetdatawin32 *sd, struct netdriverdata *tc, void *use if (!sd->evttw) goto end; sd->mtu = tc->mtu; - sd->readbuffer = xmalloc (sd->mtu); - sd->writebuffer = xmalloc (sd->mtu); + sd->readbuffer = xmalloc (uae_u8, sd->mtu); + sd->writebuffer = xmalloc (uae_u8, sd->mtu); sd->gotfunc = gotfunc; sd->getfunc = getfunc; @@ -240,8 +242,9 @@ end: return 0; } -void uaenet_close (struct uaenetdatawin32 *sd) +void uaenet_close (void *vsd) { + struct uaenetdatawin32 *sd = (struct uaenetdatawin32*)vsd; if (!sd) return; if (sd->threadactiver) { @@ -391,7 +394,7 @@ struct netdriverdata *uaenet_enumerate (struct netdriverdata **out, const TCHAR write_log (L"- PacketOpenAdapter() failed\n"); continue; } - OidData = calloc (6 + sizeof(PACKET_OID_DATA), 1); + OidData = (PPACKET_OID_DATA)xcalloc (uae_u8, 6 + sizeof(PACKET_OID_DATA)); if (OidData) { OidData->Length = 6; OidData->Oid = OID_802_3_CURRENT_ADDRESS; @@ -408,7 +411,7 @@ struct netdriverdata *uaenet_enumerate (struct netdriverdata **out, const TCHAR } else { write_log (L" - failed to get MAC\n"); } - free (OidData); + xfree (OidData); } PacketCloseAdapter (lpAdapter); } diff --git a/od-win32/win32gfx.c b/od-win32/win32gfx.cpp similarity index 99% rename from od-win32/win32gfx.c rename to od-win32/win32gfx.cpp index 654a2b4a..ba5c1ba2 100644 --- a/od-win32/win32gfx.c +++ b/od-win32/win32gfx.cpp @@ -107,6 +107,8 @@ static struct winuae_currentmode *currentmode = ¤tmodestruct; int screen_is_picasso = 0; +extern int reopen (int); + int WIN32GFX_IsPicassoScreen (void) { return screen_is_picasso; @@ -175,7 +177,7 @@ int WIN32GFX_GetHeight (void) static int init_round; static BOOL doInit (void); -uae_u32 default_freq = 0; +int default_freq = 0; HWND hStatusWnd = NULL; @@ -432,7 +434,7 @@ static void addmode (struct MultiDisplay *md, int w, int h, int d, int rate, int static HRESULT CALLBACK modesCallback (LPDDSURFACEDESC2 modeDesc, LPVOID context) { - struct MultiDisplay *md = context; + struct MultiDisplay *md = (struct MultiDisplay*)context; RGBFTYPE colortype; int depth, ct; @@ -630,7 +632,7 @@ void sortdisplays (void) md1 = Displays; while (md1->name) { - md1->DisplayModes = xmalloc (sizeof (struct PicassoResolution) * MAX_PICASSO_MODES); + md1->DisplayModes = xmalloc (struct PicassoResolution, MAX_PICASSO_MODES); md1->DisplayModes[0].depth = -1; md1->disabled = 1; if (DirectDraw_Start (md1->primary ? NULL : &md1->guid)) { @@ -712,7 +714,7 @@ void sortdisplays (void) /* DirectX will fail with "Mode not supported" if we try to switch to a full * screen mode that doesn't match one of the dimensions we got during enumeration. * So try to find a best match for the given resolution in our list. */ -int WIN32GFX_AdjustScreenmode (struct MultiDisplay *md, uae_u32 *pwidth, uae_u32 *pheight, uae_u32 *ppixbits) +int WIN32GFX_AdjustScreenmode (struct MultiDisplay *md, int *pwidth, int *pheight, int *ppixbits) { struct PicassoResolution *best; uae_u32 selected_mask = (*ppixbits == 8 ? RGBMASK_8BIT @@ -1299,7 +1301,6 @@ int check_prefs_changed_gfx (void) DirectDraw_BlitToPrimary (NULL); } if ((c & 16) || ((c & 8) && keepfsmode)) { - extern int reopen (int); if (reopen (c & 2)) c |= 2; } @@ -1966,7 +1967,7 @@ static void createstatuswindow (void) /* Allocate an array for holding the right edge coordinates. */ hloc = LocalAlloc (LHND, sizeof (int) * num_parts); if (hloc) { - lpParts = LocalLock (hloc); + lpParts = (LPINT)LocalLock (hloc); /* Calculate the right edge coordinate for each part, and copy the coords * to the array. */ lpParts[0] = rc.right - (drive_width * 4) - power_width - idle_width - fps_width - cd_width - hd_width - snd_width - extra; @@ -2174,7 +2175,7 @@ static int create_windows_2 (void) if (!dxfs && !d3dfs) { RECT rc; - LONG stored_x = 1, stored_y = cymenu + cyborder; + int stored_x = 1, stored_y = cymenu + cyborder; int oldx, oldy; int first = 2; @@ -2467,7 +2468,7 @@ static BOOL doInit (void) int w = currentmode->amiga_width * 2; int h = currentmode->amiga_height * 2; int size = (w * 2) * (h * 3) * gfxvidinfo.pixbytes; - gfxvidinfo.realbufmem = xmalloc (size); + gfxvidinfo.realbufmem = xmalloc (uae_u8, size); memset (gfxvidinfo.realbufmem, 0, size); gfxvidinfo.bufmem = gfxvidinfo.realbufmem + (w + (w * 2) * h) * gfxvidinfo.pixbytes; gfxvidinfo.rowbytes = w * 2 * gfxvidinfo.pixbytes; @@ -2476,7 +2477,7 @@ static BOOL doInit (void) } else if (currentmode->flags & DM_D3D) { int size = currentmode->amiga_width * currentmode->amiga_height * gfxvidinfo.pixbytes; - gfxvidinfo.realbufmem = xmalloc (size); + gfxvidinfo.realbufmem = xmalloc (uae_u8, size); gfxvidinfo.bufmem = gfxvidinfo.realbufmem; gfxvidinfo.rowbytes = currentmode->amiga_width * gfxvidinfo.pixbytes; gfxvidinfo.bufmemend = gfxvidinfo.bufmem + size; diff --git a/od-win32/win32gfx.h b/od-win32/win32gfx.h index a7598635..905732f1 100644 --- a/od-win32/win32gfx.h +++ b/od-win32/win32gfx.h @@ -22,11 +22,11 @@ void WIN32GFX_WindowSize (void);; void DX_Invalidate (int x, int y, int width, int height); RGBFTYPE WIN32GFX_FigurePixelFormats (RGBFTYPE colortype); -int WIN32GFX_AdjustScreenmode (struct MultiDisplay *md, uae_u32 *pwidth, uae_u32 *pheight, uae_u32 *ppixbits); +int WIN32GFX_AdjustScreenmode (struct MultiDisplay *md, int *pwidth, int *pheight, int *ppixbits); extern HCURSOR normalcursor; extern HWND hStatusWnd; -extern uae_u32 default_freq; +extern int default_freq; extern int normal_display_change_starting; extern int window_led_drives, window_led_drives_end; extern int window_led_hd, window_led_hd_end; diff --git a/od-win32/win32gui.c b/od-win32/win32gui.cpp similarity index 99% rename from od-win32/win32gui.c rename to od-win32/win32gui.cpp index cf874bb8..429983ec 100644 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.cpp @@ -135,9 +135,9 @@ void WIN32GUI_LoadUIString (DWORD id, TCHAR *string, DWORD dwStringLen) LoadString (hInst, id, string, dwStringLen); } -static DWORD quickstart_model = 0, quickstart_conf = 0, quickstart_compa = 1; -static DWORD quickstart_floppy = 1, quickstart_cd = 0; -static DWORD quickstart_cdtype = 0; +static int quickstart_model = 0, quickstart_conf = 0, quickstart_compa = 1; +static int quickstart_floppy = 1, quickstart_cd = 0; +static int quickstart_cdtype = 0; static int quickstart_ok, quickstart_ok_floppy; static void addfloppytype (HWND hDlg, int n); static void addfloppyhistory (HWND hDlg); @@ -261,10 +261,10 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode) pSHCreateItemFromParsingName = (SHCREATEITEMFROMPARSINGNAME)GetProcAddress ( GetModuleHandle (L"shell32.dll"), "SHCreateItemFromParsingName"); if (pSHCreateItemFromParsingName) - hr = CoCreateInstance (mode > 0 ? &CLSID_FileSaveDialog : &CLSID_FileOpenDialog, + hr = CoCreateInstance (mode > 0 ? __uuidof(FileSaveDialog) : __uuidof(FileOpenDialog), NULL, CLSCTX_INPROC_SERVER, - mode > 0 ? &IID_IFileSaveDialog : &IID_IFileOpenDialog, (LPVOID*)&pfd); + mode > 0 ? IID_IFileSaveDialog : IID_IFileOpenDialog, (LPVOID*)&pfd); if (FAILED (hr)) { if (mode > 0) return GetSaveFileName (opn); @@ -273,16 +273,16 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode) else return DirectorySelection2 (opn); } - IFileDialog_GetOptions (pfd, &pfos); + pfd->GetOptions (&pfos); pfos |= FOS_FORCEFILESYSTEM; if (opn->Flags & OFN_ALLOWMULTISELECT) pfos |= FOS_ALLOWMULTISELECT; if (mode < 0) pfos |= FOS_PICKFOLDERS; - IFileDialog_SetOptions (pfd, pfos); + pfd->SetOptions (pfos); if (guid) - IFileDialog_SetClientGuid (pfd, guid); + pfd->SetClientGuid (*guid); if (opn->lpstrFilter) { const TCHAR *p = opn->lpstrFilter; @@ -293,7 +293,7 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode) filtercnt++; } if (filtercnt) { - fs = xmalloc (sizeof (COMDLG_FILTERSPEC) * filtercnt); + fs = xmalloc (COMDLG_FILTERSPEC, filtercnt); p = opn->lpstrFilter; for (i = 0; i < filtercnt; i++) { fs[i].pszName = p; @@ -301,28 +301,28 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode) fs[i].pszSpec = p; p += _tcslen (p) + 1; } - IFileDialog_SetFileTypes (pfd, filtercnt, fs); + pfd->SetFileTypes (filtercnt, fs); } - IFileOpenDialog_SetFileTypeIndex (pfd, opn->nFilterIndex); + pfd->SetFileTypeIndex (opn->nFilterIndex); } if (opn->lpstrTitle) { - IFileDialog_SetTitle (pfd, opn->lpstrTitle); + pfd->SetTitle (opn->lpstrTitle); } if (opn->lpstrDefExt) { - IFileDialog_SetDefaultExtension (pfd, opn->lpstrDefExt); + pfd->SetDefaultExtension (opn->lpstrDefExt); } if (opn->lpstrInitialDir) { TCHAR tmp[MAX_DPATH]; const TCHAR *p = opn->lpstrInitialDir; if (GetFullPathName (p, sizeof tmp / sizeof (TCHAR), tmp, NULL)) p = tmp; - hr = pSHCreateItemFromParsingName (p, NULL, &IID_IShellItem, &shellitem); + hr = pSHCreateItemFromParsingName (p, NULL, IID_IShellItem, (void**)&shellitem); if (SUCCEEDED (hr)) - IFileDialog_SetFolder (pfd, shellitem); + pfd->SetFolder (shellitem); } - hr = IFileDialog_Show (pfd, opn->hwndOwner); + hr = pfd->Show (opn->hwndOwner); if (SUCCEEDED (hr)) { UINT idx; IShellItemArray *pitema; @@ -332,10 +332,10 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode) opn->lpstrFileTitle[0] = 0; if (mode > 0) { IShellItem *pitem; - hr = IFileOpenDialog_GetResult (pfd, &pitem); + hr = pfd->GetResult (&pitem); if (SUCCEEDED (hr)) { WCHAR *path = NULL; - hr = IShellItem_GetDisplayName (pitem, SIGDN_FILESYSPATH, &path); + hr = pitem->GetDisplayName (SIGDN_FILESYSPATH, &path); if (SUCCEEDED (hr)) { TCHAR *p = opn->lpstrFile; _tcscpy (p, path); @@ -344,21 +344,21 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode) if (p && opn->lpstrFileTitle) _tcscpy (opn->lpstrFileTitle, p); } - IShellItem_Release (pitem); + pitem->Release (); } } else { - hr = IFileOpenDialog_GetResults (pfd, &pitema); + hr = pfd->GetResults (&pitema); if (SUCCEEDED (hr)) { DWORD cnt; - hr = IShellItemArray_GetCount (pitema, &cnt); + hr = pitema->GetCount (&cnt); if (SUCCEEDED (hr)) { int i; for (i = 0; i < cnt; i++) { IShellItem *pitem; - hr = IShellItemArray_GetItemAt (pitema, i, &pitem); + hr = pitema->GetItemAt (i, &pitem); if (SUCCEEDED (hr)) { WCHAR *path = NULL; - hr = IShellItem_GetDisplayName (pitem, SIGDN_FILESYSPATH, &path); + hr = pitem->GetDisplayName (SIGDN_FILESYSPATH, &path); if (SUCCEEDED (hr)) { TCHAR *p = opn->lpstrFile; while (*p) @@ -377,19 +377,19 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode) } } } - IShellItemArray_Release (pitema); + pitema->Release (); } } - hr = IFileOpenDialog_GetFileTypeIndex (pfd, &idx); + hr = pfd->GetFileTypeIndex (&idx); if (SUCCEEDED (hr)) opn->nFilterIndex = idx; ret = 1; } - IFileDialog_Release (pfd); + pfd->Release (); if (shellitem) - IShellItem_Release (shellitem); + shellitem->Release (); if (filtercnt) { xfree (fs); } @@ -467,11 +467,10 @@ UAEREG *read_disk_history (int type) { static int regread; TCHAR tmp2[1000]; - DWORD size2; + int size, size2; int idx, idx2; UAEREG *fkey; TCHAR tmp[1000]; - DWORD size; fkey = regcreatetree (NULL, type ? L"CDImageMRUList" : L"DiskImageMRUList"); if (fkey == NULL || (regread & (1 << type))) @@ -687,7 +686,7 @@ static TCHAR *favoritepopup (HWND hwnd) num = 0; for (;;) { TCHAR *p; - DWORD size, size2; + int size, size2; TCHAR tmp[1000], tmp2[1000]; size = sizeof (tmp) / sizeof (TCHAR); size2 = sizeof (tmp2) / sizeof (TCHAR); @@ -857,7 +856,7 @@ static int drag_end (HWND hWnd, HWND hListView, LPARAM lParam, int **draggeditem } if (cnt == 0) return -1; - *draggeditems = xmalloc (sizeof (int) * (cnt + 1)); + *draggeditems = xmalloc (int, cnt + 1); iPos = ListView_GetNextItem(hListView, -1, LVNI_SELECTED); cnt = 0; while (iPos != -1) { @@ -934,7 +933,7 @@ static struct romdata *scan_single_rom_2 (struct zfile *f) } else { zfile_fseek (f, 0, SEEK_SET); } - rombuf = xcalloc (size, 1); + rombuf = xcalloc (uae_u8, size); if (!rombuf) return 0; zfile_fread (rombuf, 1, size, f); @@ -1036,7 +1035,7 @@ static int isromext (TCHAR *path) ext++; if (!_tcsicmp (ext, L"rom") || !_tcsicmp (ext, L"adf") || !_tcsicmp (ext, L"key") - || !_tcsicmp (ext, L"a500") || !_tcsicmp (ext, L"a1200") || !_tcsicmp (ext, L"a4000")) + || !_tcsicmp (ext, L"a500") || !_tcsicmp (ext, L"a1200") || !_tcsicmp (ext, L"a4000") || !_tcsicmp (ext, L"cd32")) return 1; if (_tcslen (ext) >= 2 && toupper(ext[0]) == 'U' && isdigit (ext[1])) return 1; @@ -1047,8 +1046,9 @@ static int isromext (TCHAR *path) return 0; } -static int scan_rom_2 (struct zfile *f, struct romscandata *rsd) +static int scan_rom_2 (struct zfile *f, void *vrsd) { + struct romscandata *rsd = (struct romscandata*)vrsd; TCHAR *path = zfile_getname(f); struct romdata *rd; @@ -1083,7 +1083,7 @@ static int scan_rom (TCHAR *path, UAEREG *fkey) } break; } - zfile_zopen (path, scan_rom_2, &rsd); + zfile_zopen (path, scan_rom_2, (void*)&rsd); return rsd.got; } @@ -1131,7 +1131,7 @@ static void show_rom_list (void) _tcscat (unavail, L"\n"); p1 = L"A500 Boot ROM 1.2\0A500 Boot ROM 1.3\0A500+\0A600\0A1000\0A1200\0A3000\0A4000\0\nCD32\0CDTV\0Arcadia Multi Select\0High end WinUAE\0\nA590/A2091 SCSI Boot ROM\0\0"; - p = malloc (100000); + p = xmalloc (TCHAR, 100000); if (!p) return; WIN32GUI_LoadUIString (IDS_ROMSCANEND, p, 100); @@ -1198,7 +1198,7 @@ static int scan_roms_2 (UAEREG *fkey, TCHAR *path) #define MAX_ROM_PATHS 10 -static int scan_roms_3(void *fkey, TCHAR **paths, TCHAR *path) +static int scan_roms_3(UAEREG *fkey, TCHAR **paths, TCHAR *path) { int i, ret; TCHAR pathp[MAX_DPATH]; @@ -1334,7 +1334,7 @@ static struct ConfigStruct *getconfigstorefrompath (TCHAR *path, TCHAR *out, int int target_cfgfile_load (struct uae_prefs *p, TCHAR *filename, int type, int isdefault) { int v, i, type2; - DWORD ct, ct2, size; + int ct, ct2, size; TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH]; TCHAR fname[MAX_DPATH]; @@ -1946,11 +1946,11 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs TCHAR disk_name[32]; disk_name[0] = 0; disk_name[31] = 0; GetDlgItemText (hDlg, IDC_CREATE_NAME, disk_name, 30); - disk_creatediskfile (full_path, 0, SendDlgItemMessage (hDlg, IDC_FLOPPYTYPE, CB_GETCURSEL, 0, 0L), disk_name); + disk_creatediskfile (full_path, 0, (drive_type)SendDlgItemMessage (hDlg, IDC_FLOPPYTYPE, CB_GETCURSEL, 0, 0L), disk_name); } break; case IDC_CREATE_RAW: - disk_creatediskfile (full_path, 1, SendDlgItemMessage(hDlg, IDC_FLOPPYTYPE, CB_GETCURSEL, 0, 0L), NULL); + disk_creatediskfile (full_path, 1, (drive_type)SendDlgItemMessage (hDlg, IDC_FLOPPYTYPE, CB_GETCURSEL, 0, 0L), NULL); break; case IDC_LOAD: if (target_cfgfile_load (&workprefs, full_path, 0, 0) == 0) { @@ -2259,7 +2259,7 @@ struct ConfigStruct *AllocConfigStruct (void) { struct ConfigStruct *config; - config = xcalloc (sizeof (struct ConfigStruct), 1); + config = xcalloc (struct ConfigStruct, 1); return config; } @@ -2421,7 +2421,7 @@ static struct ConfigStruct *readconfigcache (const TCHAR *path) cs = AllocConfigStruct (); if (configstore == NULL || configstoreallocated == configstoresize) { configstoreallocated += 100; - configstore = realloc (configstore, sizeof (struct ConfigStruct*) * configstoreallocated); + configstore = xrealloc (struct ConfigStruct*, configstore, configstoreallocated); } configstore[configstoresize++] = cs; if (!first) @@ -2703,7 +2703,7 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u config->Parent = configparent; if (configstore == NULL || configstoreallocated == configstoresize) { configstoreallocated += 100; - configstore = realloc (configstore, sizeof (struct ConfigStruct*) * configstoreallocated); + configstore = xrealloc (struct ConfigStruct*, configstore, configstoreallocated); } configstore[configstoresize++] = config; if (first == NULL) @@ -3548,7 +3548,7 @@ static struct ConfigStruct *initloadsave (HWND hDlg, struct ConfigStruct *config { HTREEITEM root; TCHAR name_buf[MAX_DPATH]; - DWORD dwRFPsize = sizeof (name_buf) / sizeof (TCHAR); + int dwRFPsize = sizeof (name_buf) / sizeof (TCHAR); TCHAR path[MAX_DPATH]; EnableWindow (GetDlgItem (hDlg, IDC_VIEWINFO), workprefs.info[0]); @@ -6312,20 +6312,6 @@ static INT_PTR CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA enable_for_memorydlg (hDlg); break; - case WM_COMMAND: - { - if (recursive > 0) - break; - recursive++; - switch (LOWORD (wParam)) - { - ; - } - if (HIWORD (wParam) == CBN_SELENDOK || HIWORD (wParam) == CBN_KILLFOCUS || HIWORD (wParam) == CBN_EDITCHANGE) { - } - recursive--; - } - break; } return FALSE; } @@ -6344,8 +6330,8 @@ static void addromfiles (UAEREG *fkey, HWND hDlg, DWORD d, TCHAR *path, int type idx = 0; seltmp[0] = 0; for (;fkey;) { - DWORD size = sizeof (tmp) / sizeof (TCHAR); - DWORD size2 = sizeof (tmp2) / sizeof (TCHAR); + int size = sizeof (tmp) / sizeof (TCHAR); + int size2 = sizeof (tmp2) / sizeof (TCHAR); if (!regenumstr (fkey, idx, tmp, &size, tmp2, &size2)) break; if (_tcslen (tmp) == 7 || _tcslen (tmp) == 13) { @@ -6624,16 +6610,16 @@ static void misc_addpri (HWND hDlg, int v, int pri) } -extern TCHAR *get_aspi_path (int); +extern const TCHAR *get_aspi_path (int); static void misc_scsi (HWND hDlg) { SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_RESETCONTENT, 0, 0); SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)L"SPTI *"); SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)L"SPTI + SCSI SCAN"); - SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path(0)) ? L"AdaptecASPI" : L"(AdaptecASPI)")); - SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path(1)) ? L"NeroASPI" : L"(NeroASPI)")); - SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path(2)) ? L"FrogASPI" : L"(FrogASPI)")); + SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path (0)) ? L"AdaptecASPI" : L"(AdaptecASPI)")); + SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path (1)) ? L"NeroASPI" : L"(NeroASPI)")); + SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path (2)) ? L"FrogASPI" : L"(FrogASPI)")); SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_SETCURSEL, workprefs.win32_uaescsimode - 1, 0); } @@ -7371,7 +7357,7 @@ static void sound_loaddrivesamples (void) if (p - drivesounds < 1000) { TCHAR *oldp = p; len += 2000; - drivesounds = p = realloc (drivesounds, len); + drivesounds = p = xrealloc (TCHAR, drivesounds, len); if (oldp) { do { p = p + _tcslen (p) + 1; @@ -8000,7 +7986,7 @@ static void sethfdostype (HWND hDlg, int idx) static void hardfile_testrdb (HWND hDlg, struct hfdlg_vals *hdf) { - void *f = zfile_fopen (hdf->filename, L"rb", ZFD_NORMAL); + struct zfile *f = zfile_fopen (hdf->filename, L"rb", ZFD_NORMAL); uae_u8 tmp[8]; int i; @@ -8904,7 +8890,7 @@ static void addfloppytype (HWND hDlg, int n) chk = !showcd && disk_getwriteprotect (text) && state == TRUE ? BST_CHECKED : 0; if (f_wp >= 0) CheckDlgButton(hDlg, f_wp, chk); - chk = !showcd && state && DISK_validate_filename (text, 0, NULL, NULL) ? TRUE : FALSE; + chk = !showcd && state && DISK_validate_filename (text, 0, NULL, NULL, NULL) ? TRUE : FALSE; if (f_wp >= 0) { ew (hDlg, f_wp, chk); ew (hDlg, f_wptext, chk); @@ -8958,7 +8944,7 @@ static int getfloppybox (HWND hDlg, int f_text, TCHAR *out, int maxlen, int type else SendDlgItemMessage (hDlg, f_text, WM_GETTEXT, (WPARAM)maxlen, (LPARAM)out); - tmp = xmalloc ((maxlen + 1) * sizeof (TCHAR)); + tmp = xmalloc (TCHAR, maxlen + 1); _tcscpy (tmp, out); p1 = _tcsstr(tmp, L" { "); p2 = _tcsstr(tmp, L" }"); @@ -9984,7 +9970,7 @@ static void init_portsdlg (HWND hDlg) EnumPrinters (flags, NULL, 1, (LPBYTE)pInfo, 0, &needed, &dwEnumeratedPrinters); if (needed > 0) { DWORD size = needed; - pInfo = xcalloc (1, size); + pInfo = (PRINTER_INFO_1*)xcalloc (uae_u8, size); dwEnumeratedPrinters = 0; EnumPrinters (flags, NULL, 1, (LPBYTE)pInfo, size, &needed, &dwEnumeratedPrinters); } @@ -11058,7 +11044,7 @@ static void values_to_hw3ddlg (HWND hDlg) if (fkey) { int idx = 0; TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH]; - DWORD size, size2; + int size, size2; for (;;) { size = sizeof (tmp) / sizeof (TCHAR); @@ -11090,7 +11076,7 @@ static void filter_preset (HWND hDlg, WPARAM wParam) { int ok, load, i, builtin, userfilter; TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH]; - DWORD outsize; + int outsize; UAEREG *fkey; LRESULT item; @@ -12142,7 +12128,7 @@ static void centerWindow (HWND hDlg) { RECT rc, rcDlg, rcOwner; HWND owner = GetParent(hDlg); - LONG x = 0, y = 0; + int x = 0, y = 0; POINT pt1, pt2; if (owner == NULL) @@ -12530,7 +12516,8 @@ struct newresource *getresource (int tmpl) HRSRC hrsrc; HGLOBAL res; HINSTANCE inst = hUIDLL ? hUIDLL : hInst; - void *resdata, *newres; + void *resdata; + LPCDLGTEMPLATEW newres; struct newresource *nr; int size; @@ -12547,9 +12534,9 @@ struct newresource *getresource (int tmpl) return NULL; resdata = LockResource (res); size = SizeofResource (inst, hrsrc); - nr = xcalloc (sizeof (struct newresource), 1); - newres = xmalloc (size); - memcpy (newres, resdata, size); + nr = xcalloc (struct newresource, 1); + newres = (LPCDLGTEMPLATEW)xmalloc (uae_u8, size); + memcpy ((void*)newres, resdata, size); nr->resource = newres; nr->size = size; nr->tmpl = tmpl; @@ -12595,7 +12582,7 @@ static int init_page (int tmpl, int icon, int title, INT_PTR (CALLBACK FAR *func) (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam), ACCEL *accels, TCHAR *help) { LPTSTR lpstrTitle; - static id = 0; + static int id = 0; int i = -1; struct newresource *res; @@ -12604,7 +12591,7 @@ static int init_page (int tmpl, int icon, int title, return -1; ppage[id].nres = res; ppage[id].icon = MAKEINTRESOURCE (icon); - lpstrTitle = calloc (1, MAX_DPATH); + lpstrTitle = xcalloc (TCHAR, MAX_DPATH); LoadString (hUIDLL, title, lpstrTitle, MAX_DPATH); ppage[id].title = lpstrTitle; ppage[id].dlgproc = func; @@ -12869,7 +12856,6 @@ void gui_exit (void) } extern HWND hStatusWnd; -struct gui_info gui_data; void check_prefs_changed_gui (void) { @@ -13067,7 +13053,8 @@ int gui_message_multibutton (int flags, const TCHAR *format,...) int flipflop = 0; int fullscreen = 0; int focuso = isfocus (); - int mbflags, ret; + int ret; + DWORD mbflags; HWND hwnd; mbflags = MB_ICONWARNING | MB_TASKMODAL; diff --git a/od-win32/win32gui.h b/od-win32/win32gui.h index 9dde7c73..654ec5bf 100644 --- a/od-win32/win32gui.h +++ b/od-win32/win32gui.h @@ -20,7 +20,7 @@ void write_disk_history (void); struct newresource { - void *resource; + LPCDLGTEMPLATEW resource; HINSTANCE inst; int size; int tmpl; diff --git a/od-win32/win32gui_extra.c b/od-win32/win32gui_extra.cpp similarity index 92% rename from od-win32/win32gui_extra.c rename to od-win32/win32gui_extra.cpp index ca9f0884..f6b4f568 100644 --- a/od-win32/win32gui_extra.c +++ b/od-win32/win32gui_extra.cpp @@ -150,23 +150,23 @@ struct newresource *scaleresource (struct newresource *res, HWND parent) int i; struct newresource *ns; - d = res->resource; - d2 = res->resource; + d = (DLGTEMPLATEEX*)res->resource; + d2 = (DLGTEMPLATEEX_END*)res->resource; if (d->dlgVer != 1 || d->signature != 0xffff) return 0; if (!(d->style & (DS_SETFONT | DS_SHELLFONT))) return 0; - ns = xcalloc (sizeof (struct newresource), 1); + ns = xcalloc (struct newresource, 1); ns->inst = res->inst; ns->size = res->size; ns->tmpl = res->tmpl; - ns->resource = xmalloc (ns->size); - memcpy (ns->resource, res->resource, ns->size); + ns->resource = (LPCDLGTEMPLATEW)xmalloc (uae_u8, ns->size); + memcpy ((void*)ns->resource, res->resource, ns->size); - d = ns->resource; - d2 = ns->resource; + d = (DLGTEMPLATEEX*)ns->resource; + d2 = (DLGTEMPLATEEX_END*)ns->resource; p = (BYTE*)d + sizeof (DLGTEMPLATEEX); p = skiptext (p); p = skiptext (p); @@ -206,7 +206,7 @@ struct newresource *scaleresource (struct newresource *res, HWND parent) void freescaleresource (struct newresource *ns) { - xfree (ns->resource); + xfree ((void*)ns->resource); xfree (ns); } diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index 6997bfbf..14fdec77 100644 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -726,47 +726,47 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > @@ -1409,19 +1409,19 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > @@ -1429,7 +1429,7 @@ Name="prowizard" > @@ -1440,47 +1440,47 @@ Name="dms" > @@ -1488,55 +1488,55 @@ Name="7z" > @@ -1544,47 +1544,47 @@ Name="lha" > @@ -1592,7 +1592,7 @@ Name="zip" > @@ -1600,7 +1600,7 @@ Name="lzx" > @@ -1612,7 +1612,7 @@ Name="wrp" > diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcproj b/od-win32/winuae_msvc10/winuae_msvc.vcproj deleted file mode 100644 index 6997bfbf..00000000 --- a/od-win32/winuae_msvc10/winuae_msvc.vcproj +++ /dev/null @@ -1,1815 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj b/od-win32/winuae_msvc10/winuae_msvc.vcxproj index 1a6d314f..13fc0967 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj @@ -124,7 +124,7 @@ %(AdditionalOptions) Disabled ..\..\include;..\..;..\;..\resources;..\osdep;..\sounddep;..\..\prowizard\include;..\tun;%(AdditionalIncludeDirectories) - WINVER=0x0500;_DEBUG;WIN32_IE=0x0700;WIN32;CINTERFACE;COBJMACROS;_CRT_SECURE_NO_WARNINGS;D3D_DEBUG_INFO;%(PreprocessorDefinitions) + WINVER=0x0500;_DEBUG;WIN32_IE=0x0700;WIN32;_CRT_SECURE_NO_WARNINGS;D3D_DEBUG_INFO;%(PreprocessorDefinitions) false false false @@ -145,6 +145,8 @@ Default 4996;%(DisableSpecificWarnings) false + false + %(ForcedIncludeFiles) _DEBUG;%(PreprocessorDefinitions) @@ -152,7 +154,7 @@ /MACHINE:I386 %(AdditionalOptions) - ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;freetype.lib;vfw32.lib;wtsapi32.lib;avrt.lib;wininet.lib;enet.lib;prowizard.lib;%(AdditionalDependencies) + ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;freetype.lib;vfw32.lib;wtsapi32.lib;enet.lib;prowizard.lib;%(AdditionalDependencies) NotSet d:\amiga\winuae.exe true @@ -167,6 +169,9 @@ false + %(AdditionalLibraryDirectories) + + ..\resources\winuae.exe.manifest;%(AdditionalManifestFiles) @@ -244,7 +249,7 @@ true false ..\..\include;..\..;..\;..\resources;..\osdep;..\sounddep;..\..\prowizard\include;%(AdditionalIncludeDirectories) - WINVER=0x0500;NDEBUG;_WIN32_IE=0x0700;WIN32;CINTERFACE;COBJMACROS;%(PreprocessorDefinitions) + WINVER=0x0500;NDEBUG;_WIN32_IE=0x0700;WIN32;%(PreprocessorDefinitions) true @@ -268,13 +273,14 @@ Default 4996;%(DisableSpecificWarnings) %(ForcedIncludeFiles) + true NDEBUG;%(PreprocessorDefinitions) 0x0409 - ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;freetype.lib;vfw32.lib;wtsapi32.lib;avrt.lib;wininet.lib;enet.lib;prowizard.lib;%(AdditionalDependencies) + ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;freetype.lib;vfw32.lib;wtsapi32.lib;enet.lib;prowizard.lib;%(AdditionalDependencies) d:\amiga\winuae.exe true %(AdditionalLibraryDirectories) @@ -387,7 +393,7 @@ true true ..\..\include;..\..;..\;..\resources;..\osdep;..\sounddep;..\..\prowizard\include;%(AdditionalIncludeDirectories) - WINVER=0x0500;NDEBUG;_WIN32_IE=0x0700;WIN32;CINTERFACE;COBJMACROS;%(PreprocessorDefinitions) + WINVER=0x0500;NDEBUG;_WIN32_IE=0x0700;WIN32;%(PreprocessorDefinitions) true @@ -411,6 +417,7 @@ Default 4996;%(DisableSpecificWarnings) %(ForcedIncludeFiles) + true NDEBUG;%(PreprocessorDefinitions) @@ -513,164 +520,164 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters index e9404334..5802e234 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters @@ -46,478 +46,478 @@ - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + win32 - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + common - + jit - + jit - + jit - + jit - + prowizard - + decompressors\dms - + decompressors\dms - + decompressors\dms - + decompressors\dms - + decompressors\dms - + decompressors\dms - + decompressors\dms - + decompressors\dms - + decompressors\dms - + decompressors\dms - + decompressors\dms - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\7z - + decompressors\lha - + decompressors\lha - + decompressors\lha - + decompressors\lha - + decompressors\lha - + decompressors\lha - + decompressors\lha - + decompressors\lha - + decompressors\lha - + decompressors\lha - + decompressors\lha - + decompressors\zip - + decompressors\lzx - + decompressors\wrp diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 30340c20..c88dc3a2 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,5 +1,20 @@ -- hpos "offset" was accidentally changed (cmp.w #0,$dff006 is possible) +Beta 11: + +- hpos "offset" was accidentally changed (DFF006 = 0000 is possible) +- .cd32 rom file extension added (missed when .a500, .a1200 and .a4000 + was added long time ago) +- b10 interrupt issues at least partially fixed (freezing or crashing demos) +- code cleanup, compiles as C++ now (do not worry, this is not "just add + hundreds of casts to make it compile") This project has gotten so big + that plain C is making things painful (for example archive filehandling + would be less messy if written properly in C++, core emulation works fine + in C, also future wxwidgets GUI is now at least theoretically possible..) + This should also make portability simpler, easier to have better + "insulation" between portable and OS specific code. Anyway, nothing + really changes until (much) later.. + Random things can be broken! Report all kinds of undocumented changes + compared to previous betas and 2.0.1. Beta 10: diff --git a/od-win32/writelog.c b/od-win32/writelog.cpp similarity index 98% rename from od-win32/writelog.c rename to od-win32/writelog.cpp index 2f91f0ed..e65ac284 100644 --- a/od-win32/writelog.c +++ b/od-win32/writelog.cpp @@ -65,7 +65,7 @@ static int cs_init; FILE *debugfile = NULL; int console_logging = 0; -static LONG debugger_type = -1; +static int debugger_type = -1; extern BOOL debuggerinitializing; int always_flush_log = 0; @@ -162,7 +162,7 @@ void reopen_console (void) hwnd = myGetConsoleWindow (); if (hwnd) { int newpos = 1; - LONG x, y, w, h; + int x, y, w, h; if (!regqueryint (NULL, L"LoggerPosX", &x)) newpos = 0; if (!regqueryint (NULL, L"LoggerPosY", &y)) @@ -427,7 +427,7 @@ void write_log (const TCHAR *format, ...) bufsize *= 10; if (bufp != buffer) xfree (bufp); - bufp = xmalloc (bufsize * sizeof (TCHAR)); + bufp = xmalloc (TCHAR, bufsize); continue; } break; @@ -495,7 +495,7 @@ TCHAR* buf_out (TCHAR *buffer, int *bufsize, const TCHAR *format, ...) return buffer + _tcslen (buffer); } -void *log_open (const TCHAR *name, int append, int bootlog) +FILE *log_open (const TCHAR *name, int append, int bootlog) { FILE *f = NULL; @@ -522,7 +522,7 @@ void *log_open (const TCHAR *name, int append, int bootlog) return f; } -void log_close (void *f) +void log_close (FILE *f) { fclose (f); } @@ -543,6 +543,3 @@ void jit_abort (const TCHAR *format,...) happened = 1; uae_reset (1); } - - - diff --git a/p96_blit.c b/p96_blit.cpp similarity index 100% rename from p96_blit.c rename to p96_blit.cpp diff --git a/picasso96.c b/picasso96.cpp similarity index 100% rename from picasso96.c rename to picasso96.cpp diff --git a/prowizard/include/extern.h b/prowizard/include/extern.h index 8655a79c..d2f7ec30 100644 --- a/prowizard/include/extern.h +++ b/prowizard/include/extern.h @@ -352,4 +352,6 @@ extern char Extensions[_KNOWN_FORMATS+1][33]; extern Uchar CONVERT; extern Uchar Amiga_EXE_Header; -extern void write_log (const char *, ...); \ No newline at end of file +extern void pw_write_log (const char *, ...); +extern FILE *moduleripper2_fopen (const char *name, const char *mode, const char *aid, int addr, int size); +extern FILE *moduleripper_fopen (const char *aname, const char *amode); diff --git a/prowizard/include/globals.h b/prowizard/include/globals.h index 047e1361..a32710ba 100644 --- a/prowizard/include/globals.h +++ b/prowizard/include/globals.h @@ -21,7 +21,6 @@ typedef unsigned char Uchar; typedef unsigned long Ulong; typedef unsigned short Ushort; -#include "moduleripper.h" #ifdef _WIN32 __inline Ulong htonlx (Ulong v) { diff --git a/prowizard/misc/misc.c b/prowizard/misc/misc.c index e88369a7..46f1233c 100644 --- a/prowizard/misc/misc.c +++ b/prowizard/misc/misc.c @@ -229,17 +229,17 @@ void Support_Types_FileDefault ( void ) void Save_Rip ( char * format_to_save, int FMT_EXT ) { Save_Status = BAD; - write_log ( "%s found at %ld !. its size is : %ld\n", format_to_save , PW_Start_Address , OutputSize ); + pw_write_log ( "%s found at %ld !. its size is : %ld\n", format_to_save , PW_Start_Address , OutputSize ); if ( (PW_Start_Address + (long)OutputSize) > PW_in_size ) { - write_log ( "!!! Truncated, missing (%ld byte(s) !)\n" + pw_write_log ( "!!! Truncated, missing (%ld byte(s) !)\n" , (PW_Start_Address+OutputSize)-PW_in_size ); PW_i += 2 ; return; } BZERO ( OutName_final, sizeof OutName_final); sprintf ( OutName_final , "%ld.%s" , Cpt_Filename , Extensions[FMT_EXT] ); - write_log ( " saving in file \"%s\" ... " , OutName_final ); + pw_write_log ( " saving in file \"%s\" ... " , OutName_final ); Cpt_Filename += 1; PW_out = moduleripper2_fopen ( OutName_final , "w+b", format_to_save, PW_Start_Address, OutputSize); //PW_out = PW_fopen ( OutName_final , "w+b" ); @@ -247,10 +247,10 @@ void Save_Rip ( char * format_to_save, int FMT_EXT ) return; fwrite ( &in_data[PW_Start_Address] , OutputSize , 1 , PW_out ); fclose ( PW_out ); - write_log ( "done\n" ); + pw_write_log ( "done\n" ); if ( CONVERT == GOOD ) { - write_log ( " converting to Protracker ... " ); + pw_write_log ( " converting to Protracker ... " ); } //fflush ( stdout ); Save_Status = GOOD; @@ -263,31 +263,31 @@ void Save_Rip ( char * format_to_save, int FMT_EXT ) void Save_Rip_Special ( char * format_to_save, int FMT_EXT, Uchar * Header_Block , Ulong Block_Size ) { Save_Status = BAD; - write_log ( "%s found at %ld !. its size is : %ld\n", format_to_save , PW_Start_Address , OutputSize ); + pw_write_log ( "%s found at %ld !. its size is : %ld\n", format_to_save , PW_Start_Address , OutputSize ); if ( (PW_Start_Address + (long)OutputSize) > PW_in_size ) { - write_log ( "!!! Truncated, missing (%ld byte(s) !)\n" + pw_write_log ( "!!! Truncated, missing (%ld byte(s) !)\n" , (PW_Start_Address+OutputSize)-PW_in_size ); PW_i += 2 ; return; } BZERO (OutName_final, sizeof OutName_final); sprintf ( OutName_final , "%ld.%s" , Cpt_Filename , Extensions[FMT_EXT] ); - write_log ( " saving in file \"%s\" ... " , OutName_final ); + pw_write_log ( " saving in file \"%s\" ... " , OutName_final ); Cpt_Filename += 1; // PW_out = PW_fopen ( OutName_final , "w+b" ); PW_out = moduleripper2_fopen ( OutName_final , "w+b", format_to_save, PW_Start_Address, OutputSize ); fwrite ( Header_Block , Block_Size , 1 , PW_out ); fwrite ( &in_data[PW_Start_Address] , OutputSize , 1 , PW_out ); fclose ( PW_out ); - write_log ( "done\n" ); + pw_write_log ( "done\n" ); if ( CONVERT == GOOD ) { - write_log ( " converting to Protracker ... " ); + pw_write_log ( " converting to Protracker ... " ); } - write_log ( " Header of this file was missing and has been rebuilt !\n" ); + pw_write_log ( " Header of this file was missing and has been rebuilt !\n" ); if ( FMT_EXT == DragPack252) - write_log ( " WARNING !: it's a fake header since in this case !!\n" ); + pw_write_log ( " WARNING !: it's a fake header since in this case !!\n" ); //fflush ( stdout ); Amiga_EXE_Header = GOOD; Save_Status = GOOD; diff --git a/readcpu.c b/readcpu.cpp similarity index 99% rename from readcpu.c rename to readcpu.cpp index 09aae600..5a1cdfea 100644 --- a/readcpu.c +++ b/readcpu.cpp @@ -773,7 +773,7 @@ void read_table68k (void) int i; free (table68k); - table68k = (struct instr *)xmalloc (65536 * sizeof (struct instr)); + table68k = xmalloc (struct instr, 65536); for (i = 0; i < 65536; i++) { table68k[i].mnemo = i_ILLG; table68k[i].handler = -1; diff --git a/readdisk.c b/readdisk.cpp similarity index 100% rename from readdisk.c rename to readdisk.cpp diff --git a/rommgr.c b/rommgr.cpp similarity index 98% rename from rommgr.c rename to rommgr.cpp index e73f8eec..7c114ff0 100644 --- a/rommgr.c +++ b/rommgr.cpp @@ -66,7 +66,7 @@ void romlist_add (TCHAR *path, struct romdata *rd) return; } romlist_cnt++; - rl = realloc (rl, sizeof (struct romlist) * romlist_cnt); + rl = xrealloc (struct romlist, rl, romlist_cnt); rl2 = rl + romlist_cnt - 1; rl2->path = my_strdup (path); rl2->rd = rd; @@ -325,7 +325,7 @@ void romlist_clear (void) TCHAR *newpn; if (parent->partnumber == NULL) parent->partnumber = my_strdup (L""); - newpn = xcalloc ((_tcslen (parent->partnumber) + 1 + _tcslen (rd->partnumber) + 1) * sizeof (TCHAR), 1); + newpn = xcalloc (TCHAR, _tcslen (parent->partnumber) + 1 + _tcslen (rd->partnumber) + 1); if (_tcslen (parent->partnumber) > 0) { _tcscpy (newpn, parent->partnumber); _tcscat (newpn, L"/"); @@ -390,7 +390,7 @@ struct romlist **getromlistbyident(int ver, int rev, int subver, int subrev, TCH max = i; else max = romlist_cnt; - buf = xmalloc ((sizeof (struct romlist*) + sizeof (struct romlist)) * (i + 1)); + buf = xmalloc (uae_u8, (sizeof (struct romlist*) + sizeof (struct romlist)) * (i + 1)); rdout = (struct romlist**)buf; rltmp = (struct romlist*)((uae_u8*)buf + (i + 1) * sizeof (struct romlist*)); out = 0; @@ -485,7 +485,7 @@ struct romlist **getarcadiaroms(void) if (roms[i].group == 0 && (roms[i].type == ROMTYPE_ARCADIABIOS || roms[i].type == ROMTYPE_ARCADIAGAME)) max++; } - buf = xmalloc ((sizeof (struct romlist*) + sizeof (struct romlist)) * (max + 1)); + buf = xmalloc (uae_u8, (sizeof (struct romlist*) + sizeof (struct romlist)) * (max + 1)); rdout = (struct romlist**)buf; rltmp = (struct romlist*)((uae_u8*)buf + (max + 1) * sizeof (struct romlist*)); out = 0; @@ -567,7 +567,7 @@ static void addkeyfile (const TCHAR *path) keysize = zfile_ftell (f); if (keysize > 0) { zfile_fseek (f, 0, SEEK_SET); - keybuf = xmalloc (keysize); + keybuf = xmalloc (uae_u8, keysize); zfile_fread (keybuf, 1, keysize, f); addkey (keybuf, keysize, path); } @@ -856,7 +856,7 @@ struct romdata *getromdatabydata (uae_u8 *rom, int size) struct romdata *ret = NULL; if (size > 11 && !memcmp (rom, "AMIROMTYPE1", 11)) { - uae_u8 *tmpbuf = xmalloc (size); + uae_u8 *tmpbuf = xmalloc (uae_u8, size); int tmpsize = size - 11; memcpy (tmpbuf, rom + 11, tmpsize); decode_rom (tmpbuf, tmpsize, 1, tmpsize); @@ -865,7 +865,7 @@ struct romdata *getromdatabydata (uae_u8 *rom, int size) } #if 0 if (size > 0x6c + 524288 && !memcmp (rom, "AMIG", 4)) { - uae_u8 *tmpbuf = (uae_u8*)xmalloc (size); + uae_u8 *tmpbuf = (uae_u8*)xmalloc (uae_u8, size); int tmpsize = size - 0x6c; memcpy (tmpbuf, rom + 0x6c, tmpsize); decode_rom (tmpbuf, tmpsize, 2, tmpsize); @@ -900,7 +900,7 @@ struct romdata *getromdatabyzfile (struct zfile *f) pos = zfile_ftell (f); zfile_fseek (f, 0, SEEK_END); size = zfile_ftell (f); - p = xmalloc (size); + p = xmalloc (uae_u8, size); if (!p) return 0; memset (p, 0, size); @@ -1079,7 +1079,7 @@ struct zfile *read_rom (struct romdata **prd) size = rd2->size; crc32 = rd2->crc32; name = rd->name; - buf = xmalloc (size * 2); + buf = xmalloc (uae_u8, size * 2); memset (buf, 0xff, size * 2); if (!buf) return NULL; @@ -1201,7 +1201,7 @@ struct zfile *read_rom_name (const TCHAR *filename) zfile_fseek (f, 0, SEEK_END); size = zfile_ftell (f) - sizeof tmp; zfile_fseek (f, sizeof tmp, SEEK_SET); - buf = xmalloc (size); + buf = xmalloc (uae_u8, size); zfile_fread (buf, size, 1, f); df = zfile_fopen_empty (f, L"tmp.rom", size); decode_cloanto_rom_do (buf, size, size); diff --git a/rpc.c b/rpc.cpp similarity index 100% rename from rpc.c rename to rpc.cpp diff --git a/sampler.c b/sampler.cpp similarity index 98% rename from sampler.c rename to sampler.cpp index c8c7a323..51ab261a 100644 --- a/sampler.c +++ b/sampler.cpp @@ -59,7 +59,7 @@ static int capture_init (void) write_log (L"SAMPLER: DirectSoundCaptureBuffer_Start failed: %s\n", DXError (hr)); return 0; } - samplebuffer = xcalloc (SAMPLEBUFFER, 1); + samplebuffer = xcalloc (uae_u8, SAMPLEBUFFER); write_log (L"SAMPLER: Parallel port sampler initialized\n"); return 1; } diff --git a/sana2.c b/sana2.cpp similarity index 99% rename from sana2.c rename to sana2.cpp index c43e98cf..26f3e4f7 100644 --- a/sana2.c +++ b/sana2.cpp @@ -390,7 +390,7 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) if (dev->opencnt == 0) { dev->unit = unit; - dev->sysdata = xcalloc (uaenet_getdatalenght(), 1); + dev->sysdata = xcalloc (uae_u8, uaenet_getdatalenght ()); if (!uaenet_open (dev->sysdata, pdev->td, dev, uaenet_gotdata, uaenet_getdata, pdev->promiscuous)) { xfree (dev->sysdata); dev->sysdata = NULL; @@ -495,7 +495,7 @@ static void add_async_packet (struct devstruct *dev, struct s2packet *s2p, uaecp { struct asyncreq *ar, *ar2; - ar = (struct asyncreq*)xcalloc (sizeof (struct asyncreq), 1); + ar = xcalloc (struct asyncreq, 1); ar->s2p = s2p; if (!dev->s2p) { dev->s2p = ar; @@ -559,7 +559,7 @@ static int add_async_request (struct devstruct *dev, uaecptr request) write_log (L"%s:%d async request %x added\n", getdevname(), dev->unit, request); uae_sem_wait (&async_sem); - ar = (struct asyncreq*)xcalloc (sizeof (struct asyncreq), 1); + ar = xcalloc (struct asyncreq, 1); ar->request = request; if (!dev->ar) { dev->ar = ar; @@ -710,7 +710,7 @@ static void addmulticastaddresses (struct devstruct *dev, uae_u64 start, uae_u64 } mc = mc->next; } - mc = xcalloc (sizeof (struct mcast), 1); + mc = xcalloc (struct mcast, 1); mc->start = start; mc->end = end; mc->cnt = 1; @@ -751,8 +751,8 @@ static int delmulticastaddresses (struct devstruct *dev, uae_u64 start, uae_u64 static struct s2packet *createreadpacket (struct devstruct *dev, const uae_u8 *d, int len) { - struct s2packet *s2p = xcalloc (sizeof (struct s2packet), 1); - s2p->data = xmalloc (dev->td->mtu + ETH_HEADER_SIZE + 2); + struct s2packet *s2p = xcalloc (struct s2packet, 1); + s2p->data = xmalloc (uae_u8, dev->td->mtu + ETH_HEADER_SIZE + 2); memcpy (s2p->data, d, len); s2p->len = len; return s2p; @@ -865,8 +865,8 @@ static struct s2packet *createwritepacket (TrapContext *ctx, uaecptr request) return NULL; if (!copyfrombuff (ctx, data, pdev->tempbuf, datalength, pdev->copyfrombuff)) return NULL; - s2p = xcalloc (sizeof (struct s2packet), 1); - s2p->data = xmalloc (pdev->td->mtu + ETH_HEADER_SIZE + 2); + s2p = xcalloc (struct s2packet, 1); + s2p->data = xmalloc (uae_u8, pdev->td->mtu + ETH_HEADER_SIZE + 2); if (flags & SANA2IOF_RAW) { memcpyah_safe (s2p->data, pdev->tempbuf, datalength); packettype = (s2p->data[2 * ADDR_SIZE + 0] << 8) | (s2p->data[2 * ADDR_SIZE + 1]); diff --git a/savestate.c b/savestate.cpp similarity index 99% rename from savestate.c rename to savestate.cpp index 05bea49c..f0483305 100644 --- a/savestate.c +++ b/savestate.cpp @@ -202,12 +202,12 @@ TCHAR *restore_string_func (uae_u8 **dstp) char *top, *to; TCHAR *s; - len = strlen(dst) + 1; - top = to = (char*)malloc (len); + len = strlen ((char*)dst) + 1; + top = to = xmalloc (char, len); do { v = *dst++; *top++ = v; - } while(v); + } while (v); *dstp = dst; s = au (to); xfree (to); @@ -292,7 +292,7 @@ static uae_u8 *restore_chunk (struct zfile *f, TCHAR *name, size_t *len, size_t /* chunk name */ zfile_fread (tmp, 1, 4, f); tmp[4] = 0; - au_copy (name, 5, tmp); + au_copy (name, 5, (char*)tmp); /* chunk size */ zfile_fread (tmp, 1, 4, f); src = tmp; @@ -330,7 +330,7 @@ static uae_u8 *restore_chunk (struct zfile *f, TCHAR *name, size_t *len, size_t && _tcscmp (name, L"A3K2") != 0) { /* without zeros at the end old state files may not work */ - mem = calloc (1, *totallen + 32); + mem = xcalloc (uae_u8, *totallen + 32); if (flags & 1) { zfile_zuncompress (mem, *totallen, f, len2); } else { @@ -380,7 +380,7 @@ static uae_u8 *restore_log (uae_u8 *src) write_log (L"%s\n", s); xfree (s); #endif - src += strlen (src) + 1; + src += strlen ((char*)src) + 1; return src; } @@ -685,7 +685,7 @@ int save_state (const TCHAR *filename, const TCHAR *description) int len, len2, i; uae_u8 *tmp; len = zfile_ftell (f) - pos; - tmp = xmalloc (len); + tmp = xmalloc (uae_u8, len); zfile_fseek(f, pos, SEEK_SET); len2 = zfile_fread (tmp, 1, len, f); for (i = 0; i < len2; i++) @@ -1208,7 +1208,7 @@ void savestate_init (void) frameextra = 0; if (currprefs.statecapture && currprefs.statecapturebuffersize && currprefs.statecapturerate) { replaybuffersize = currprefs.statecapturebuffersize; - replaybuffer = xmalloc (replaybuffersize); + replaybuffer = xmalloc (uae_u8, replaybuffersize); } } diff --git a/scsi.c b/scsi.cpp similarity index 95% rename from scsi.c rename to scsi.cpp index 2518ca26..d0d6804e 100644 --- a/scsi.c +++ b/scsi.cpp @@ -88,7 +88,7 @@ void scsi_emulate_cmd(struct scsi_data *sd) struct scsi_data *scsi_alloc(int id, struct hd_hardfiledata *hfd) { - struct scsi_data *sd = (struct scsi_data*)xcalloc(sizeof (struct scsi_data), 1); + struct scsi_data *sd = xcalloc (struct scsi_data, 1); sd->hfd = hfd; sd->id = id; sd->nativescsiunit = -1; @@ -102,7 +102,7 @@ struct scsi_data *scsi_alloc_native(int id, int nativeunit) write_log (L"SCSI: native scsi unit %d failed to open\n", nativeunit); return NULL; } - sd = (struct scsi_data*)xcalloc(sizeof (struct scsi_data), 1); + sd = xcalloc (struct scsi_data, 1); sd->id = id; sd->nativescsiunit = nativeunit; return sd; diff --git a/scsidev.c b/scsidev.cpp similarity index 100% rename from scsidev.c rename to scsidev.cpp diff --git a/scsiemul.c b/scsiemul.cpp similarity index 100% rename from scsiemul.c rename to scsiemul.cpp diff --git a/serial.c b/serial.cpp similarity index 100% rename from serial.c rename to serial.cpp diff --git a/sinctable.c b/sinctable.cpp similarity index 100% rename from sinctable.c rename to sinctable.cpp diff --git a/traps.c b/traps.cpp similarity index 99% rename from traps.c rename to traps.cpp index 4b71bce2..bdc4ec3a 100644 --- a/traps.c +++ b/traps.cpp @@ -269,7 +269,7 @@ static void *trap_thread (void *arg) */ static void trap_HandleExtendedTrap (TrapHandler handler_func, int has_retval) { - struct TrapContext *context = calloc (1, sizeof (TrapContext)); + struct TrapContext *context = xcalloc (TrapContext, 1); if (context) { uae_sem_init (&context->switch_to_trap_sem, 0, 0); @@ -426,7 +426,7 @@ static uae_u32 REGPARAM3 exit_trap_handler (TrapContext *dummy_ctx) uae_sem_destroy (&context->switch_to_trap_sem); uae_sem_destroy (&context->switch_to_emu_sem); - free (context); + xfree (context); /* End critical section */ uae_sem_post (&trap_mutex); diff --git a/uaeexe.c b/uaeexe.cpp similarity index 95% rename from uaeexe.c rename to uaeexe.cpp index d2102be0..c2b656bf 100644 --- a/uaeexe.c +++ b/uaeexe.cpp @@ -51,12 +51,12 @@ int uaeexe (const TCHAR *cmd) if (!running) goto NORUN; - nw = malloc (sizeof *nw); + nw = xmalloc (struct uae_xcmd, 1); if (!nw) goto NOMEM; - nw->cmd = malloc ((_tcslen (cmd) + 1) * sizeof (TCHAR)); + nw->cmd = xmalloc (TCHAR, _tcslen (cmd) + 1); if (!nw->cmd) { - free (nw); + xfree (nw); goto NOMEM; } diff --git a/uaeipc.c b/uaeipc.cpp similarity index 88% rename from uaeipc.c rename to uaeipc.cpp index 9f6fee20..329523db 100644 --- a/uaeipc.c +++ b/uaeipc.cpp @@ -59,8 +59,9 @@ static void parsemessage(TCHAR *in, struct uae_prefs *p, TCHAR *out, int outsize } } -static int listenIPC(struct uaeipc *ipc) +static int listenIPC (void *vipc) { + struct uaeipc *ipc = (struct uaeipc*)vipc; DWORD err; memset(&ipc->ol, 0, sizeof (OVERLAPPED)); @@ -85,8 +86,9 @@ static int listenIPC(struct uaeipc *ipc) return 1; } -static void disconnectIPC(struct uaeipc *ipc) +static void disconnectIPC (void *vipc) { + struct uaeipc *ipc = (struct uaeipc*)vipc; ipc->readpending = ipc->writepending = FALSE; if (ipc->connected) { if (!DisconnectNamedPipe(ipc->hipc)) @@ -95,20 +97,22 @@ static void disconnectIPC(struct uaeipc *ipc) } } -static void resetIPC(struct uaeipc *ipc) +static void resetIPC (void *vipc) { - disconnectIPC(ipc); - listenIPC(ipc); + struct uaeipc *ipc = (struct uaeipc*)vipc; + disconnectIPC (ipc); + listenIPC (ipc); } -void closeIPC(struct uaeipc *ipc) +void closeIPC (void *vipc) { + struct uaeipc *ipc = (struct uaeipc*)vipc; if (!ipc) return; - disconnectIPC(ipc); + disconnectIPC (ipc); if (ipc->hipc == INVALID_HANDLE_VALUE) return; - CloseHandle(ipc->hipc); + CloseHandle (ipc->hipc); ipc->hipc = INVALID_HANDLE_VALUE; if (ipc->olevent != INVALID_HANDLE_VALUE) CloseHandle (ipc->olevent); @@ -116,13 +120,13 @@ void closeIPC(struct uaeipc *ipc) xfree (ipc); } -void *createIPC(const TCHAR *name, int binary) +void *createIPC (const TCHAR *name, int binary) { TCHAR tmpname[100]; int cnt = 0; struct uaeipc *ipc; - ipc = xcalloc (sizeof (struct uaeipc), 1); + ipc = xcalloc (struct uaeipc, 1); ipc->connected = FALSE; ipc->readpending = FALSE; ipc->writepending = FALSE; @@ -157,13 +161,15 @@ void *createIPC(const TCHAR *name, int binary) return NULL; } -void *geteventhandleIPC(struct uaeipc *ipc) +void *geteventhandleIPC (void *vipc) { + struct uaeipc *ipc = (struct uaeipc*)vipc; return ipc->olevent; } -int sendIPC(struct uaeipc *ipc, TCHAR *msg) +int sendIPC (void *vipc, TCHAR *msg) { + struct uaeipc *ipc = (struct uaeipc*)vipc; if (ipc->hipc == INVALID_HANDLE_VALUE) return 0; if (ipc->outmessages >= MAX_OUTMESSAGES) @@ -173,8 +179,9 @@ int sendIPC(struct uaeipc *ipc, TCHAR *msg) SetEvent (ipc->olevent); return 1; } -int sendBinIPC(struct uaeipc *ipc, uae_u8 *msg, int len) +int sendBinIPC (void *vipc, uae_u8 *msg, int len) { + struct uaeipc *ipc = (struct uaeipc*)vipc; if (ipc->hipc == INVALID_HANDLE_VALUE) return 0; if (ipc->outmessages >= MAX_OUTMESSAGES) @@ -186,8 +193,9 @@ int sendBinIPC(struct uaeipc *ipc, uae_u8 *msg, int len) return 1; } -int checkIPC(struct uaeipc *ipc, struct uae_prefs *p) +int checkIPC (void *vipc, struct uae_prefs *p) { + struct uaeipc *ipc = (struct uaeipc*)vipc; BOOL ok; DWORD ret, err; @@ -274,7 +282,7 @@ int checkIPC(struct uaeipc *ipc, struct uae_prefs *p) int isIPC (const TCHAR *pipename) { - HANDLE *p; + HANDLE p; p = CreateFile( pipename, diff --git a/uaelib.c b/uaelib.cpp similarity index 100% rename from uaelib.c rename to uaelib.cpp diff --git a/uaeresource.c b/uaeresource.cpp similarity index 100% rename from uaeresource.c rename to uaeresource.cpp diff --git a/uaeserial.c b/uaeserial.cpp similarity index 99% rename from uaeserial.c rename to uaeserial.cpp index 743ce7f1..441bcc78 100644 --- a/uaeserial.c +++ b/uaeserial.cpp @@ -277,7 +277,7 @@ static uae_u32 REGPARAM2 dev_open (TrapContext *context) if (i == MAX_TOTAL_DEVICES) return openfail (ioreq, IOERR_OPENFAIL); dev = &devst[i]; - dev->sysdata = xcalloc (uaeser_getdatalenght(), 1); + dev->sysdata = xcalloc (uae_u8, uaeser_getdatalenght ()); if (!uaeser_open (dev->sysdata, dev, unit)) { xfree (dev->sysdata); return openfail (ioreq, IOERR_OPENFAIL); @@ -337,7 +337,7 @@ static int add_async_request (struct devstruct *dev, uaecptr request) write_log (L"%s:%d async request %x added\n", getdevname(), dev->unit, request); uae_sem_wait (&async_sem); - ar = (struct asyncreq*)xcalloc (sizeof (struct asyncreq), 1); + ar = xcalloc (struct asyncreq, 1); ar->request = request; if (!dev->ar) { dev->ar = ar; @@ -400,8 +400,9 @@ static uae_u8 *memmap(uae_u32 addr, uae_u32 len) return bank_data->xlateaddr (addr); } -void uaeser_signal (struct devstruct *dev, int sigmask) +void uaeser_signal (void *vdev, int sigmask) { + struct devstruct *dev = (struct devstruct*)vdev; struct asyncreq *ar; int i = 0; diff --git a/uaeunp.c b/uaeunp.cpp similarity index 98% rename from uaeunp.c rename to uaeunp.cpp index 4029c656..7ec5a98a 100644 --- a/uaeunp.c +++ b/uaeunp.cpp @@ -203,7 +203,7 @@ static void resetlist (void) static int unlist2 (struct arcdir *adp, const TCHAR *src, int all) { struct zvolume *zv; - void *h; + struct zdirectory *h; int i; TCHAR p[MAX_DPATH]; TCHAR fn[MAX_DPATH]; @@ -230,7 +230,7 @@ static int unlist2 (struct arcdir *adp, const TCHAR *src, int all) while (zfile_readdir_archive (h, fn)) { struct _stat64 st; int isdir; - uae_u32 flags; + int flags; TCHAR *comment; struct zfile *zf; uae_u32 crc32 = 0; @@ -288,7 +288,7 @@ static int unlist2 (struct arcdir *adp, const TCHAR *src, int all) if (parentid >= 0) return 1; - filelist = xmalloc (entries * sizeof (struct arcdir*)); + filelist = xmalloc (struct arcdir*, entries); for (i = 0; i < entries; i++) { filelist[i] = &adp[i]; } @@ -316,7 +316,7 @@ static int unlist2 (struct arcdir *adp, const TCHAR *src, int all) static int unlist (const TCHAR *src, int all) { struct arcdir *adp; - adp = xcalloc (sizeof (struct arcdir), maxentries); + adp = xcalloc (struct arcdir, maxentries); unlist2 (adp, src, all); return 1; } @@ -369,7 +369,7 @@ static int found; static int unpack (const TCHAR *src, const TCHAR *filename, const TCHAR *dst, int out, int all, int level) { - void *h; + struct zdirectory *h; struct zvolume *zv; int ret; uae_u8 *b; @@ -430,7 +430,7 @@ static int unpack (const TCHAR *src, const TCHAR *filename, const TCHAR *dst, in zfile_fseek (s, 0, SEEK_END); size = zfile_ftell (s); zfile_fseek (s, 0, SEEK_SET); - b = xcalloc (size, 1); + b = xcalloc (uae_u8, size); if (b) { if (zfile_fread (b, size, 1, s) == 1) { if (out) { @@ -464,7 +464,7 @@ static int unpack (const TCHAR *src, const TCHAR *filename, const TCHAR *dst, in static int unpack2 (const TCHAR *src, const TCHAR *match, int level) { - void *h; + struct zdirectory *h; struct zvolume *zv; int ret; uae_u8 *b; @@ -523,7 +523,7 @@ static int unpack2 (const TCHAR *src, const TCHAR *match, int level) zfile_fseek (s, 0, SEEK_END); size = zfile_ftell (s); zfile_fseek (s, 0, SEEK_SET); - b = xcalloc (size, 1); + b = xcalloc (uae_u8, size); if (b) { if (zfile_fread (b, size, 1, s) == 1) { d = zfile_fopen (dst, L"wb", 0); @@ -551,7 +551,7 @@ static int unpack2 (const TCHAR *src, const TCHAR *match, int level) static int scanpath (TCHAR *src, TCHAR *outpath) { struct zvolume *zv; - void *h; + struct zdirectory *h; TCHAR fn[MAX_DPATH]; zv = zfile_fopen_archive_root (src); diff --git a/writelog.c b/writelog.cpp similarity index 100% rename from writelog.c rename to writelog.cpp diff --git a/zfile.c b/zfile.cpp similarity index 96% rename from zfile.c rename to zfile.cpp index af9c8cc2..419f50d9 100644 --- a/zfile.c +++ b/zfile.cpp @@ -139,7 +139,7 @@ static struct zcache *zcache_put (const TCHAR *name, struct zdiskimage *data) struct zcache *zc; zcache_check (); - zc = xcalloc (sizeof (struct zcache), 1); + zc = xcalloc (struct zcache, 1); zc->next = zcachedata; zcachedata = zc; zc->zd = data; @@ -152,7 +152,7 @@ static struct zfile *zfile_create (struct zfile *prev) { struct zfile *z; - z = xmalloc (sizeof *z); + z = xmalloc (struct zfile, 1); if (!z) return 0; memset (z, 0, sizeof *z); @@ -329,13 +329,14 @@ struct zfile_vhd }; -static uae_u64 vhd_fread2 (struct zfile *zf, uae_u8 *dataptr, uae_u64 offset, uae_u64 len) +static uae_u64 vhd_fread2 (struct zfile *zf, void *dataptrv, uae_u64 offset, uae_u64 len) { uae_u32 bamoffset; uae_u32 sectoroffset; uae_u64 read; struct zfile *zp = zf->parent; - struct zfile_vhd *zvhd = zf->userdata; + struct zfile_vhd *zvhd = (struct zfile_vhd*)zf->userdata; + uae_u8 *dataptr = (uae_u8*)dataptrv; //write_log (L"%08x %08x\n", (uae_u32)offset, (uae_u32)len); read = 0; @@ -384,21 +385,20 @@ static uae_u64 vhd_fread2 (struct zfile *zf, uae_u8 *dataptr, uae_u64 offset, ua } return read; } -static uae_u64 vhd_fread (uae_u8 *data, uae_u64 l1, uae_u64 l2, struct zfile *zf) +static uae_s64 vhd_fread (void *data, uae_u64 l1, uae_u64 l2, struct zfile *zf) { uae_u64 size = l1 * l2; uae_u64 out = 0; int len = 0; if ((zf->seek & 511) || (size & 511)) { - int seek; uae_u8 tmp[512]; if (zf->seek & 511) { int s; s = 512 - (zf->seek & 511); vhd_fread2 (zf, tmp, zf->seek & ~511, 512); - memcpy (data + len, tmp + 512 - s, s); + memcpy ((uae_u8*)data + len, tmp + 512 - s, s); len += s; out += s; zf->seek += s; @@ -406,7 +406,7 @@ static uae_u64 vhd_fread (uae_u8 *data, uae_u64 l1, uae_u64 l2, struct zfile *zf while (size > 0) { int s = size > 512 ? 512 : size; vhd_fread2 (zf, tmp, zf->seek, 512); - memcpy (data + len, tmp, s); + memcpy ((uae_u8*)data + len, tmp, s); zf->seek += s; size -= s; out += s; @@ -426,7 +426,7 @@ static struct zfile *vhd (struct zfile *z) struct zfile_vhd *zvhd; uae_u64 fsize; - zvhd = xcalloc (sizeof (struct zfile_vhd), 1); + zvhd = xcalloc (struct zfile_vhd, 1); zfile_fseek (z, 0, SEEK_END); fsize = zfile_ftell (z); zfile_fseek (z, 0, SEEK_SET); @@ -472,11 +472,11 @@ static struct zfile *vhd (struct zfile *z) zvhd->vhd_bamoffset = gl (tmp + 8 + 8 + 4); zvhd->vhd_bamsize = (((zvhd->virtsize + zvhd->vhd_blocksize - 1) / zvhd->vhd_blocksize) * 4 + 511) & ~511; size = zvhd->vhd_bamoffset + zvhd->vhd_bamsize; - zvhd->vhd_header = xmalloc (size); + zvhd->vhd_header = xmalloc (uae_u8, size); zfile_fseek (z, 0, SEEK_SET); if (zfile_fread (zvhd->vhd_header, 1, size, z) != size) goto end; - zvhd->vhd_sectormap = xmalloc (512); + zvhd->vhd_sectormap = xmalloc (uae_u8, 512); zvhd->vhd_sectormapblock = -1; zvhd->vhd_bitmapsize = ((zvhd->vhd_blocksize / (8 * 512)) + 511) & ~511; } @@ -589,7 +589,7 @@ static void truncate880k (struct zfile *z) return; if (z->size < 880 * 512 * 2) { int size = 880 * 512 * 2 - z->size; - b = xcalloc (size, 1); + b = xcalloc (uae_u8, size); zfile_fwrite (b, size, 1, z); xfree (b); return; @@ -619,9 +619,9 @@ static struct zfile *extadf (struct zfile *z, int index, int *retcode) if (index > 1) return NULL; - mfm = xcalloc (32000, 1); - amigamfmbuffer = xcalloc (32000, 1); - outbuf = xcalloc (16384, 1); + mfm = xcalloc (uae_u16, 32000 / 2); + amigamfmbuffer = xcalloc (uae_u16, 32000 / 2); + outbuf = xcalloc (uae_u8, 16384); zfile_fread (buffer, 1, 8, z); zfile_fread (buffer, 1, 4, z); @@ -734,15 +734,15 @@ static struct zfile *fdi (struct zfile *z, int index, int *retcode) fdi = fdi2raw_header (z); if (!fdi) return NULL; - mfm = xcalloc (32000, 1); - zd = xcalloc (sizeof (struct zdiskimage), 1); + mfm = xcalloc (uae_u16, 32000 / 2); + zd = xcalloc (struct zdiskimage, 1); tracks = fdi2raw_get_last_track (fdi); zd->tracks = tracks; for (i = 0; i < tracks; i++) { uae_u8 *buf, *p; fdi2raw_loadtrack (fdi, mfm, NULL, i, &len, NULL, NULL, 1); len /= 8; - buf = p = xmalloc (len); + buf = p = xmalloc (uae_u8, len); for (j = 0; j < len / 2; j++) { uae_u16 v = mfm[j]; *p++ = v >> 8; @@ -755,8 +755,8 @@ static struct zfile *fdi (struct zfile *z, int index, int *retcode) zc = zcache_put (z->name, zd); } - amigamfmbuffer = xcalloc (32000, 1); - outbuf = xcalloc (16384, 1); + amigamfmbuffer = xcalloc (uae_u16, 32000 / 2); + outbuf = xcalloc (uae_u8, 16384); tracks = zc->zd->tracks; if (ext) { _tcscpy (newname, orgname); @@ -786,7 +786,7 @@ static struct zfile *fdi (struct zfile *z, int index, int *retcode) } outsize = 0; for (i = 0; i < tracks; i++) { - uae_u8 *p = zc->zd->zdisktracks[i].data; + uae_u8 *p = (uae_u8*)zc->zd->zdisktracks[i].data; len = zc->zd->zdisktracks[i].len; memset (writebuffer_ok, 0, sizeof writebuffer_ok); memset (outbuf, 0, 16384); @@ -861,8 +861,8 @@ static struct zfile *ipf (struct zfile *z, int index, int *retcode) struct zdiskimage *zd; if (!caps_loadimage (z, 0, &tracks)) return NULL; - mfm = xcalloc (32000, 1); - zd = xcalloc (sizeof (struct zdiskimage), 1); + mfm = xcalloc (uae_u16, 32000 / 2); + zd = xcalloc (struct zdiskimage, 1); zd->tracks = tracks; for (i = 0; i < tracks; i++) { uae_u8 *buf, *p; @@ -870,7 +870,7 @@ static struct zfile *ipf (struct zfile *z, int index, int *retcode) caps_loadtrack (mfm, NULL, 0, i, &len, &mrev, &gapo); //write_log (L"%d: %d %d %d\n", i, mrev, gapo, len); len /= 8; - buf = p = xmalloc (len); + buf = p = xmalloc (uae_u8, len); for (j = 0; j < len / 2; j++) { uae_u16 v = mfm[j]; *p++ = v >> 8; @@ -883,8 +883,8 @@ static struct zfile *ipf (struct zfile *z, int index, int *retcode) zc = zcache_put (z->name, zd); } - outbuf = xcalloc (16384, 1); - amigamfmbuffer = xcalloc (32000, 1); + outbuf = xcalloc (uae_u8, 16384); + amigamfmbuffer = xcalloc (uae_u16, 32000 / 2); if (ext) { _tcscpy (newname, orgname); _tcscpy (newname + _tcslen (newname) - _tcslen (ext), L".adf"); @@ -919,7 +919,7 @@ static struct zfile *ipf (struct zfile *z, int index, int *retcode) outsize = 0; for (i = 0; i < tracks; i++) { - uae_u8 *p = zc->zd->zdisktracks[i].data; + uae_u8 *p = (uae_u8*)zc->zd->zdisktracks[i].data; len = zc->zd->zdisktracks[i].len; memset (writebuffer_ok, 0, sizeof writebuffer_ok); memset (outbuf, 0, 16384); @@ -999,7 +999,7 @@ static struct zfile *dsq (struct zfile *z, int lzx) size = 1760 * 512; if (zfile_getfilename (zi) && _tcslen (zfile_getfilename (zi))) { - fn = xmalloc ((_tcslen (zfile_getfilename (zi)) + 5) * sizeof (TCHAR)); + fn = xmalloc (TCHAR, (_tcslen (zfile_getfilename (zi)) + 5)); _tcscpy (fn, zfile_getfilename (zi)); _tcscat (fn, L".adf"); } else { @@ -1076,7 +1076,7 @@ static struct zfile *dms (struct zfile *z, int index, int *retcode) if (index > 0) { zfile_fclose (zo); zo = NULL; - for (i = 0; i < zextra[i]; i++); + for (i = 0; i < DMS_EXTRA_SIZE && zextra[i]; i++); if (index > i) goto end; zo = zextra[index - 1]; @@ -1105,7 +1105,7 @@ const TCHAR *uae_diskimageextensions[] = int zfile_is_ignore_ext (const TCHAR *name) { int i; - TCHAR *ext; + const TCHAR *ext; ext = _tcsrchr (name, '.'); if (!ext) @@ -1121,7 +1121,7 @@ int zfile_is_diskimage (const TCHAR *name) { int i; - TCHAR *ext = _tcsrchr (name, '.'); + const TCHAR *ext = _tcsrchr (name, '.'); if (!ext) return 0; i = 0; @@ -1647,7 +1647,7 @@ static struct zfile *zfile_fopen_internet (const TCHAR *name, const TCHAR *mode, } datalen = 0; - data = malloc (bufferlen); + data = xmalloc (uae_u8, bufferlen); for (;;) { if (!InternetReadFile (i, data + datalen, INETBUFFERLEN, &didread)) { DWORD err = GetLastError (); @@ -1661,7 +1661,7 @@ static struct zfile *zfile_fopen_internet (const TCHAR *name, const TCHAR *mode, datalen += didread; if (datalen > bufferlen - INETBUFFERLEN) { bufferlen += INETBUFFERLEN; - data = realloc (data, bufferlen); + data = xrealloc (uae_u8, data, bufferlen); if (!data) { datalen = 0; break; @@ -1757,7 +1757,7 @@ struct zfile *zfile_dup (struct zfile *zf) nzf = zfile_create (zf); } else if (zf->data) { nzf = zfile_create (zf); - nzf->data = xmalloc (zf->size); + nzf->data = xmalloc (uae_u8, zf->size); memcpy (nzf->data, zf->data, zf->size); nzf->size = zf->size; } else if (zf->zipname) { @@ -1801,14 +1801,14 @@ struct zfile *zfile_fopen_empty (struct zfile *prev, const TCHAR *name, uae_u64 l = zfile_create (prev); l->name = name ? my_strdup (name) : L""; if (size) { - l->data = xcalloc (size, 1); + l->data = xcalloc (uae_u8, size); if (!l->data) { xfree (l); return NULL; } l->size = size; } else { - l->data = xcalloc (1, 1); + l->data = xcalloc (uae_u8, 1); l->size = 0; } return l; @@ -1845,7 +1845,7 @@ struct zfile *zfile_fopen_data (const TCHAR *name, uae_u64 size, uae_u8 *data) l = zfile_create (NULL); l->name = name ? my_strdup (name) : L""; - l->data = xmalloc (size); + l->data = xmalloc (uae_u8, size); l->size = size; memcpy (l->data, data, size); return l; @@ -1858,7 +1858,6 @@ uae_s64 zfile_size (struct zfile *z) uae_s64 zfile_ftell (struct zfile *z) { - uae_s64 v; if (z->data || z->dataseek || z->parent) return z->seek; return _ftelli64 (z->f); @@ -1898,7 +1897,7 @@ uae_s64 zfile_fseek (struct zfile *z, uae_s64 offset, int mode) return 1; } -size_t zfile_fread (void *b, size_t l1, size_t l2,struct zfile *z) +size_t zfile_fread (void *b, size_t l1, size_t l2, struct zfile *z) { if (z->zfileread) return z->zfileread (b, l1, l2, z); @@ -1946,7 +1945,7 @@ size_t zfile_fwrite (void *b, size_t l1, size_t l2, struct zfile *z) if (z->data) { int off = z->seek + l1 * l2; if (off > z->size) { - z->data = realloc (z->data, off); + z->data = xrealloc (uae_u8, z->data, off); z->size = off; } memcpy (z->data + z->seek, b, l1 * l2); @@ -2060,7 +2059,7 @@ uae_u8 *zfile_getdata (struct zfile *z, uae_s64 offset, int len) len = zfile_ftell (z); zfile_fseek (z, 0, SEEK_SET); } - b = xmalloc (len); + b = xmalloc (uae_u8, len); if (z->data) { memcpy (b, z->data + offset, len); } else { @@ -2158,7 +2157,7 @@ uae_u32 zfile_crc32 (struct zfile *f) pos = zfile_ftell (f); zfile_fseek (f, 0, SEEK_END); size = zfile_ftell (f); - p = xmalloc (size); + p = xmalloc (uae_u8, size); if (!p) return 0; memset (p, 0, size); @@ -2194,7 +2193,7 @@ static struct znode *znode_alloc (struct znode *parent, const TCHAR *name) { TCHAR fullpath[MAX_DPATH]; TCHAR tmpname[MAX_DPATH]; - struct znode *zn = xcalloc (sizeof (struct znode), 1); + struct znode *zn = xcalloc (struct znode, 1); struct znode *zn2; TCHAR sep[] = { FSDB_DIR_SEPARATOR, 0 }; @@ -2284,7 +2283,7 @@ static void zvolume_addtolist (struct zvolume *zv) static struct zvolume *zvolume_alloc_2 (const TCHAR *name, struct zfile *z, unsigned int id, void *handle, const TCHAR *volname) { - struct zvolume *zv = xcalloc (sizeof (struct zvolume), 1); + struct zvolume *zv = xcalloc (struct zvolume, 1); struct znode *root; uae_s64 pos; int i; @@ -2689,7 +2688,7 @@ struct znode *zvolume_addfile_abs (struct zvolume *zv, struct zarchive_info *zai struct zvolume *zfile_fopen_directory (const TCHAR *dirname) { struct zvolume *zv = NULL; - void *dir; + struct my_opendir_s *dir; TCHAR fname[MAX_DPATH]; dir = my_opendir (dirname); @@ -2858,7 +2857,7 @@ struct zdirectory { struct znode *n; }; -void *zfile_opendir_archive (const TCHAR *path) +struct zdirectory *zfile_opendir_archive (const TCHAR *path) { struct zvolume *zv = get_zvolume (path); struct znode *zn = get_znode (zv, path, TRUE); @@ -2866,7 +2865,7 @@ void *zfile_opendir_archive (const TCHAR *path) if (!zn || (!zn->child && !zn->vchild)) return NULL; - zd = xmalloc (sizeof (struct zdirectory)); + zd = xmalloc (struct zdirectory, 1); if (zn->child) { zd->n = zn->child; } else { @@ -2945,24 +2944,24 @@ int zfile_stat_archive (const TCHAR *path, struct _stat64 *s) return 1; } -uae_s64 zfile_lseek_archive (void *d, uae_s64 offset, int whence) +uae_s64 zfile_lseek_archive (struct zfile *d, uae_s64 offset, int whence) { if (zfile_fseek (d, offset, whence)) return -1; return zfile_ftell (d); } -unsigned int zfile_read_archive (void *d, void *b, unsigned int size) +unsigned int zfile_read_archive (struct zfile *d, void *b, unsigned int size) { return zfile_fread (b, 1, size, d); } -void zfile_close_archive (void *d) +void zfile_close_archive (struct zfile *d) { /* do nothing, keep file cached */ } -void *zfile_open_archive (const TCHAR *path, int flags) +struct zfile *zfile_open_archive (const TCHAR *path, int flags) { struct zvolume *zv = get_zvolume (path); struct znode *zn = get_znode (zv, path, TRUE); @@ -2998,10 +2997,8 @@ int zfile_exists_archive (const TCHAR *path, const TCHAR *rel) int zfile_convertimage (const TCHAR *src, const TCHAR *dst) { struct zfile *s, *d; - struct zvolume *zv; int ret = 0; - zv = zfile_open_archive (src, 0); s = zfile_fopen (src, L"rb", ZFD_NORMAL); if (s) { uae_u8 *b; @@ -3009,7 +3006,7 @@ int zfile_convertimage (const TCHAR *src, const TCHAR *dst) zfile_fseek (s, 0, SEEK_END); size = zfile_ftell (s); zfile_fseek (s, 0, SEEK_SET); - b = xcalloc (size, 1); + b = xcalloc (uae_u8, size); if (b) { if (zfile_fread (b, size, 1, s) == 1) { d = zfile_fopen (dst, L"wb", 0); diff --git a/zfile_archive.c b/zfile_archive.cpp similarity index 97% rename from zfile_archive.c rename to zfile_archive.cpp index 2b7cd94d..1fa0df53 100644 --- a/zfile_archive.c +++ b/zfile_archive.cpp @@ -286,8 +286,8 @@ struct zvolume *archive_directory_tar (struct zfile *z) ustar = 1; name[0] = 0; if (ustar) - strcpy (name, block + 345); - strcat (name, block); + strcpy (name, (char*)block + 345); + strcat (name, (char*)block); if (name[0] == 0) valid = 0; @@ -296,13 +296,13 @@ struct zvolume *archive_directory_tar (struct zfile *z) if (ustar && (block[256] != 0 && block[256] != '0')) valid = 0; - size = _strtoui64 (block + 124, NULL, 8); + size = _strtoui64 ((char*)block + 124, NULL, 8); if (valid) { memset (&zai, 0, sizeof zai); zai.name = au (name); zai.size = size; - zai.t = _strtoui64 (block + 136, NULL, 8); + zai.t = _strtoui64 ((char*)block + 136, NULL, 8); zai.t += _timezone; if (_daylight) zai.t -= 1 * 60 * 60; @@ -425,7 +425,7 @@ struct zfile *archive_access_zip (struct znode *zn) s = NULL; if (unzOpenCurrentFile (uz) != UNZ_OK) return 0; - z = zfile_fopen_empty (uz, zn->fullname, zn->size); + z = zfile_fopen_empty (NULL, zn->fullname, zn->size); if (z) { err = unzReadCurrentFile (uz, z->data, zn->size); } @@ -499,10 +499,11 @@ struct SevenZContext UInt32 blockIndex; }; -static void archive_close_7z (struct SevenZContext *ctx) +static void archive_close_7z (void *ctx) { - SzArEx_Free (&ctx->db, &allocImp); - allocImp.Free (&allocImp, ctx->outBuffer); + struct SevenZContext *ctx7 = (struct SevenZContext*)ctx; + SzArEx_Free (&ctx7->db, &allocImp); + allocImp.Free (&allocImp, ctx7->outBuffer); xfree (ctx); } @@ -517,7 +518,7 @@ struct zvolume *archive_directory_7z (struct zfile *z) struct SevenZContext *ctx; init_7z (); - ctx = xcalloc (sizeof (struct SevenZContext), 1); + ctx = xcalloc (struct SevenZContext, 1); ctx->blockIndex = 0xffffffff; ctx->archiveStream.s.Read = SzFileReadImp; ctx->archiveStream.s.Seek = SzFileSeekImp; @@ -572,7 +573,7 @@ struct zfile *archive_access_7z (struct znode *zn) size_t outSizeProcessed; struct SevenZContext *ctx; - ctx = zv->handle; + ctx = (struct SevenZContext*)zv->handle; res = SzAr_Extract (&ctx->db, &ctx->lookStream.s, zn->offset, &ctx->blockIndex, &ctx->outBuffer, &ctx->outBufferSize, &offset, &outSizeProcessed, @@ -672,9 +673,9 @@ static int rar_resetf (struct zfile *z) return 1; } -static void archive_close_rar (struct RARContext *rc) +static void archive_close_rar (void *ctx) { - xfree (rc); + xfree ((struct RARContext*)ctx); } struct zvolume *archive_directory_rar (struct zfile *z) @@ -689,7 +690,7 @@ struct zvolume *archive_directory_rar (struct zfile *z) if (z->data) /* wtf? stupid unrar.dll only accept filename as an input.. */ return archive_directory_arcacc (z, ArchiveFormatRAR); - rc = xcalloc (sizeof (struct RARContext), 1); + rc = xcalloc (struct RARContext, 1); zv = zvolume_alloc (z, ArchiveFormatRAR, rc, NULL); //fclose (z->f); /* bleh, unrar.dll fails to open the archive if it is already open.. */ //z->f = NULL; @@ -728,7 +729,7 @@ struct zvolume *archive_directory_rar (struct zfile *z) struct zfile *archive_access_rar (struct znode *zn) { - struct RARContext *rc = zn->volume->handle; + struct RARContext *rc = (struct RARContext*)zn->volume->handle; int i; struct zfile *zf = NULL; @@ -965,8 +966,8 @@ static struct znode *addfile (struct zvolume *zv, struct zfile *zf, const TCHAR z = zfile_fopen_empty (zf, path, size); zfile_fwrite (data, size, 1, z); - memset(&zai, 0, sizeof zai); - zai.name = path; + memset (&zai, 0, sizeof zai); + zai.name = my_strdup (path); zai.flags = -1; zai.size = size; zn = zvolume_addfile_abs (zv, &zai); @@ -974,6 +975,7 @@ static struct znode *addfile (struct zvolume *zv, struct zfile *zf, const TCHAR zn->f = z; else zfile_fclose (z); + xfree (zai.name); return zn; } @@ -1000,10 +1002,10 @@ struct zvolume *archive_directory_plain (struct zfile *z) zfile_fseek(z, 0, SEEK_SET); zn = zvolume_addfile_abs (zv, &zai); if (!memcmp (id, exeheader, sizeof id)) { - uae_u8 *an = ua (zai.name); - uae_u8 *data = xmalloc (1 + strlen (an) + 1 + 1 + 1); + 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", data, strlen (data)); + zn = addfile (zv, z, L"s/startup-sequence", (uae_u8*)data, strlen (data)); xfree (data); xfree (an); } @@ -1149,7 +1151,7 @@ static void recurseadf (struct znode *zn, int root, TCHAR *name) { int i; struct zvolume *zv = zn->volume; - struct adfhandle *adf = zv->handle; + struct adfhandle *adf = (struct adfhandle*)zv->handle; TCHAR name2[MAX_DPATH]; int bs = adf->blocksize; @@ -1207,7 +1209,7 @@ static void recurseadf (struct znode *zn, int root, TCHAR *name) static void recursesfs (struct znode *zn, int root, TCHAR *name, int sfs2) { struct zvolume *zv = zn->volume; - struct adfhandle *adf = zv->handle; + struct adfhandle *adf = (struct adfhandle*)zv->handle; TCHAR name2[MAX_DPATH]; int bs = adf->blocksize; int block; @@ -1227,7 +1229,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 (s); + fname = au ((char*)s); i = 0; while (*s) { s++; @@ -1236,7 +1238,7 @@ static void recursesfs (struct znode *zn, int root, TCHAR *name, int sfs2) s++; i++; if (*s) - zai.comment = au (s); + zai.comment = au ((char*)s); while (*s) { s++; i++; @@ -1297,7 +1299,7 @@ struct zvolume *archive_directory_adf (struct znode *parent, struct zfile *z) TCHAR name[MAX_DPATH]; int gotroot = 0; - adf = xcalloc (sizeof (struct adfhandle), 1); + adf = xcalloc (struct adfhandle, 1); zfile_fseek (z, 0, SEEK_END); adf->size = zfile_ftell (z); zfile_fseek (z, 0, SEEK_SET); @@ -1461,7 +1463,7 @@ static int sfsfindblock (struct adfhandle *adf, int btree, int theblock, struct struct sfsblock *sb; if (*sfsblockcnt >= *sfsmaxblockcnt) { *sfsmaxblockcnt += 100; - *sfsb = realloc (*sfsb, (*sfsmaxblockcnt) * sizeof (struct sfsblock)); + *sfsb = xrealloc (struct sfsblock, *sfsb, *sfsmaxblockcnt); } sb = *sfsb + (*sfsblockcnt); sb->block = key; @@ -1490,7 +1492,7 @@ struct zfile *archive_access_adf (struct znode *zn) { struct zfile *z = NULL; int root, ffs; - struct adfhandle *adf = zn->volume->handle; + struct adfhandle *adf = (struct adfhandle*)zn->volume->handle; int size, bs; int i; uae_u8 *dst; @@ -1587,7 +1589,7 @@ end: static void archive_close_adf (void *v) { - struct adfhandle *adf = v; + struct adfhandle *adf = (struct adfhandle*)v; xfree (adf); } @@ -1902,7 +1904,7 @@ static void fatdirectory (struct zfile *z, struct zvolume *zv, TCHAR *name, int } fatname[cnt] = 0; - fname = au (fatname); + fname = au ((char*)fatname); name2[0] = 0; if (name[0]) { TCHAR sep[] = { FSDB_DIR_SEPARATOR, 0 }; -- 2.47.3