Commit graph

953 commits

Author SHA1 Message Date
PeterLemon 1c1118462b
Update README.md
Added latest Windows Build instructions, & extra help
2023-05-29 05:24:38 +01:00
Jason Benaim ee6db7d803 Don't crash when N64's framebuffer exceeds 8MB. Wrap aroudn in that case. 2022-10-01 23:46:23 -07:00
Jay Oster 73ad38ca3f Fix buffer overflow in IS Viewer 64
- Fixes #211
2022-06-21 17:44:21 +02:00
PeterLemon 2dc9dac36f
Merge pull request #230 from carmiker/master
ai: Implement non-assembly byteswapping routine for audio samples
2022-06-19 21:05:57 +01:00
Rupert Carmichael d1775488da ai: Implement non-assembly byteswapping routine for audio samples 2022-06-19 15:57:46 -04:00
PeterLemon 9092d1cc40
Merge pull request #229 from carmiker/master
ai: Fix segfault when built against musl-libc
2022-06-19 20:49:45 +01:00
Rupert Carmichael 3615ddf5b9 ai: Fix segfault when built against musl-libc 2022-06-19 15:39:23 -04:00
Giovanni Bajo 474bf4782c vr4300: implement DADE exception.
Very likely to be wrong in details, but still better than an abort.
2022-05-29 23:26:04 +02:00
Giovanni Bajo da84018e6e vr4300: implement RANDOM register reading, and fix TLB index masking 2022-05-29 23:26:04 +02:00
Giovanni Bajo cf38848d5b Convert some asserts into regular code.
No need to assert for unlikely cases that can happen.
2022-05-29 23:26:04 +02:00
Giovanni Bajo 9f488ea96a vr4300: implement LL/SC as LW/SW
The real implementation is harder because it conflicts with how the
the VR4300 pipeline is emulated, but at the end of the day in the happy
path these functions are LW/SW. So instead of just refusing to emulate
them, better fallback to LW/SW.
2022-05-29 23:26:04 +02:00
Lionel Touati ca4bd81817
Add support for SDL on MACOS (#226) 2022-05-21 13:51:34 +02:00
Giovanni Bajo f70312008a Help users discover -is-viewer
IS Viewer emulation is currently gated by a command-line flag. All
other major emulators supporting ISViewer (Ares, dillonb, m64p) enable
it by default, and it does not seem to create any problem.

To help homebrew developers discover the feature without showing logs
by default, change the code to always emulate the ISViewer hardware
and add a warning if the ROM uses it but the command line flag was
not specified. This should point users towards correct usage, and
prevents possibly-verbose logs to be shown by default.
2022-03-26 00:12:14 +01:00
Giovanni Bajo 71903c63fa Add support for homebrew-specific special header flag
Nintendo 64 homebrew community is standardizing on a convention to
declare the save memory type as a header flag. This convention has been
first introduced by EverDrive 64 as a way to handle games not present
in their DB, but it's been since adopted by libdragon as well.

With this commit, cen64 will automatically configure the correct savetype
for homebrew ROMs using the special header flag.

I've also added support for a 1Mbit SRAM savetype. This was never used
in commercial games but it is available with EverDrive64 and is one of
the possible configuration options. It costs nothing to support it and
may help development of homebrew games that decide to use that savetype.
2022-03-25 23:30:54 +01:00
Giovanni Bajo 5431cd25b3 cen64: cleanup console/windowed support
Currently, the experience of cen64 binaries of Windows is not the
greatest, to be kind. If you get the binary and double-click on it,
you get nothing (no feedback whatsoever). If you run it from the
console, you get nothing (no command line help is shown). I am not sure
how Windows users ever manage to use it.

This happens because the binary is linked as a windowed application,
but when run with no command line applications, it exits after printing
the help with printf, which does nothing since no console is
attached to the windowed application.

This PR improves the usability on Windows. It compiles cen64 has a
console application (as was meant to be used), so that the help text
or any other stdout/stderr output is now visible on console. Moreover,
to provide a decent experience to users double-clicking on the
binary, it displays an error message explaining that it should be run
from the command line instead.
2022-03-19 22:59:20 +01:00
Giovanni Bajo aa32804889 Fix CI Windows build
pthread.h has changed path in recent msys2 builds.
2022-03-19 15:05:28 +01:00
Adam Gashlin d386930fa2 Avoid length overflow when fetch starts beyond ROM 2022-01-24 18:41:03 +01:00
Giovanni Bajo 0902da8113 Fix SRA/SRAV opcodes
These opcodes surprisingly let the 33th bit shift in into the lower 32-bits,
before sign-extension.
2022-01-18 23:47:28 +01:00
Christopher Bonhage 9f264b3208 Emulate SRAM bank boundaries in PI read/write 2021-12-17 21:18:48 +01:00
Christopher Bonhage 6b7c2af8d4 Add support for 768Kbit SRAM save type
Fixes a Segfault when loading Dezaemon 3D.

  * Unfortunately, Dezaemon 3D does not actually work yet. It appears to
    fail the SRAM test, which still needs further investigation.

Adds an option alias for sram256k to disambiguate with new sram768k option.
2021-12-17 21:18:48 +01:00
Giovanni Bajo 87ebca00b5 Fix a few pipelining bugs with RSP
1) Setting SP_PC was not resetting the pipeline. This caused that
changing the PC within a HALT/UNHALT sequence was still causing
previous instructions in the pipeline (at the old address) to be
executed. This is not how the hardware works: SP_PC is immediate and
discards the whole pipeline.

2) BREAK did not correctly halt the processor at the right instruction,
which in turn caused resumption after HALT to execute the wrong
set of instructions. This was caused by the fact that the SP_STATUS
change was written into the EXDF latch, which in turn takes 3 cycles
to reach completion. Instead, we now use the DFWB latch, and we cause
it to abort the RSP cycle if the processor is halted. This happens
at the beginning of next cycle, which is the correct moment.

2bis) Since we are at it, use rsp_status_write to modify the RSP in
this case, rather than a direct write to the register. This change
fixes a race condition: SP_STATUS must be accessed atomically when
cen64 runs in multithreaded mode. To use rsp_status_write, we need
to introduce a nonexisting SP_SET_BROKE bit: we use the MSB, but then
mask it out in MTC0 to avoid some code to inadvertently have that bit
set.

3) When unhalting after BREAK, it's important to keep the correct
PC which comes from the EX stage (the one that was going to be
executed if BREAK didn't occur). Before, it was using the IF PC (fetch)
which is farther in the future.

Fixes #155
2021-12-17 00:23:47 +01:00
Simon Eriksson d6b5b04395 Fix arch/x86_64/rsp warnings 2021-09-07 23:11:00 +02:00
Giovanni Bajo 87ed667c38 Show Windows console when isviewer is present. 2021-09-06 23:35:40 +02:00
Christopher Bonhage 95f8dd1f02 Fix heading of os/common/local_time.c 2021-09-04 22:02:29 +02:00
Christopher Bonhage 8f64dcd8b3 Implement RTC write support
* Set local time offset when writing to Joybus or 64DD RTC.
* Refactor get_local_time to use ISO C Time APIs.

Special thanks to @jago85 and @LuigiBlood for their research!
2021-09-04 22:02:29 +02:00
Christopher Bonhage 202d2359c1 Fix buffer overflow vulnerability in pif_process
https://github.com/n64dev/cen64/issues/122
2021-07-25 20:03:58 +02:00
Simon Eriksson 6362964386
Merge pull request #203 from meeq/fix/eeprom-detection
Fix EEPROM detection Joybus status response
2021-06-26 22:33:26 +02:00
Christopher Bonhage 8c461e64c7 Improve accuracy of PIF commands
Based on EEPROM test ROM run on real hardware.
2021-06-24 07:09:06 -04:00
Christopher Bonhage 6629191f26 Resolve implicit fallthrough warnings 2021-06-24 07:09:06 -04:00
Christopher Bonhage a87c2d70f6 Fix "No EEPROM present" Joybus status response 2021-06-24 07:09:06 -04:00
Simon Eriksson 5503dd0efb
Merge pull request #189 from networkfusion/github-actions
Add Github Action workflows
2021-06-23 20:12:40 +02:00
Giovanni Bajo 8367698e20 Improve PI DMA implementation.
This is now basically perfect compared to real hardware. Verified
used the extensive testsuite here: https://github.com/rasky/n64_pi_dma_test

The only missing part is timing and making the transfer happen in
background, at least block by block.
2021-06-23 20:11:44 +02:00
Giovanni Bajo a56fa4ba41 Fix two bugs in COP0 count
First, since the internal register is kept in CPU cycles (not RCP cycles),
we need to double the value written via MTC0/DMTC0.

Second, writing a count equal to compare would cause an infinite loop
because the fault would be triggered while PC was on the instruction
doing MTC0 itself, which would be then re-executed at the end of the
exception. On real hardware, in general, when COUNT==COMPARE, the
interrupt happens a few cycles later, enough for PC to move to other
opcodes. Instead of trying to implement this, I've simply made sure
that the interrupt happened after the opcode was executed rather than
before. Also, since the internal counter is in CPU cycles, we make
sure to only raise the CAUSE bit once.
2021-06-13 23:19:07 +02:00
Giovanni Bajo 6abe0f7e55 Fix several bugs in PI DMA alignments and register reads 2021-06-07 20:36:15 +02:00
Robin Jones 42509bb74d Merge branch 'n64dev:master' into github-actions 2021-05-17 12:58:52 +01:00
Simon Eriksson eb935a85f7 rsp: Align RSP memory address in DMA to 8 2021-05-04 18:45:54 +02:00
Giovanni Bajo 622dd402f0 vr4300: fix badvaddr register in TLB exceptions.
Currently, all load/store opcodes (with the exception of LWL/LWR) mask
the lowest bit of address that causes a TLB exception in the BADVADDR
COP0 register. This is wrong because the VR4300 reports the exact
faulting address in that register, the reason being that the exception
handler must require it.
2021-05-04 00:23:24 +02:00
James Lambert 1b31ca9b3c Report full pc instead of truncated address 2021-03-12 18:20:02 +01:00
Simon Eriksson 9316569eff pi: Fix PI DMA length alignment
Fixes Yoshi's Story, F-1 World Grand Prix and probably many other games
2021-03-09 22:20:12 +01:00
James Lambert deda9f9709 Have debugger handle memory exceptions 2021-03-08 20:17:17 +01:00
Simon Eriksson 27917c7df8 rsp: Fix VNOP and VNULL 2021-03-08 20:07:19 +01:00
Simon Eriksson 89e47d2968 Add Dinosaur Planet to cart DB 2021-02-20 18:39:05 +01:00
Simon Eriksson a54cbe042f si: Fix Memory Pak initialization
Thanks to bryc for researching this issue and reviewing this fix
2021-02-20 18:11:07 +01:00
Simon Eriksson 6f9f5784bf vr4300: Fix improper handling of valid bit in TLB probe function
This fix restores GoldenEye support (#78)
2021-02-19 23:42:00 +01:00
Robin Jones 18ea3be0fb Remove un-necessary cmake change. 2021-01-22 16:09:50 +00:00
Robin Jones e05b42fb9e Check linux workflow builds. 2021-01-22 14:06:52 +00:00
Robin Jones 000b620a3a Update iconv and openal links in readme. 2021-01-22 13:57:20 +00:00
Robin Jones ac4b35b618 Cleanup toolchain file. 2021-01-22 13:36:16 +00:00
Robin Jones f95259754d Add module path 2021-01-22 13:26:27 +00:00
Robin Jones 43160673bf Add Github Action workflows 2021-01-22 12:04:57 +00:00