Comments (3)
The following is a small test program that can demonstrate the aforementioned bug in a reproducible fashion.
uint8_t *memory_to_test = n64_malloc(127);
for (uint8_t i=0;i<127;i++) {
memory_to_test[i] = i+1;
}
uint8_t *second_buffer = n64_malloc(127);
n64_memmove(second_buffer, memory_to_test, 127);
for (uint8_t i=0;i<127;i++) {
if(memory_to_test[i] != second_buffer[i]) {
printf("%d != %d @ %d\n", memory_to_test[i], second_buffer[i], i);
}
}
n64_free(second_buffer);
n64_free(memory_to_test);
The output of the test program is:
125 != 0 @ 124
126 != 0 @ 125
127 != 0 @ 126
from 64doom.
The following is a corrected version of the "n64_memmove" function.
I will push this change to the GIT repository by 2016-05-05 00:00:00 EST.
void *n64_memmove(void *dest, const void *src, size_t size)
{
int i;
void *tmp = (void *)n64_malloc(size);
if (ALIGNED(dest) && ALIGNED(src))
{
uint32_t *wd = (uint32_t*)dest;
uint32_t *ws = (uint32_t*)src;
int size_in_uint32_ts = size >> 2;
int size_in_bytes = size % 4;
uint8_t *bd = (uint8_t*)(dest + (size_in_uint32_ts << 2));
uint8_t *bs = (uint8_t*)(src + (size_in_uint32_ts << 2));
uint32_t *wtmp;
uint8_t *btmp;
wtmp = (uint32_t*)tmp;
for (i=0;i<size_in_uint32_ts;i++)
{
wtmp[i] = ws[i];
}
for (i=0;i<size_in_uint32_ts;i++)
{
wd[i] = wtmp[i];
}
btmp = (uint8_t*)(tmp + (size_in_uint32_ts << 2));
for (i=0;i<size_in_bytes;i++)
{
btmp[i] = bs[i];
}
for (i=0;i<size_in_bytes;i++)
{
bd[i] = btmp[i];
}
}
else
{
uint8_t *d = (uint8_t*)dest;
uint8_t *s = (uint8_t*)src;
uint8_t *btmp = (uint8_t*)tmp;
for (i=0;i<size;i++)
{
btmp[i] = s[i];
}
for (i=0;i<size;i++)
{
d[i] = btmp[i];
}
}
n64_free(tmp);
return dest;
}
from 64doom.
resolved, no longer using
from 64doom.
Related Issues (20)
- Windows compatibility issues HOT 1
- Fix for Windows Compatability Issues HOT 2
- Windows 10 N64TOOL issue? HOT 18
- when i do all the steps i dont get any z64 files of "DOOMU.Z64"
- sticky strafe HOT 1
- InitTextures - Misaligned read error HOT 4
- Update memset in AM_clearFB
- Top beveled edge takes palette changes from item pickup if message on screen HOT 2
- Game not overscan safe HOT 2
- Dont mix channels in memory HOT 1
- Add WAD select at startup HOT 1
- Bunny screen glitch
- Error complaints being thrown up by compiler HOT 4
- fixed-point trig approximations without tables HOT 5
- Add SD Card Support HOT 1
- Built ROM doesn't function on RetroArch cores HOT 1
- Compiler throws odd "display_get" and "display_try_get" errors HOT 2
- Cheat menu. HOT 1
- Linking errors on Ubuntu 22.04 HOT 6
- Built ROMs cause constant NMI calls
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 64doom.