cj1128 / chip8-emulator Goto Github PK
View Code? Open in Web Editor NEW🎉 A simple CHIP-8 emulator written with C and SDL2
🎉 A simple CHIP-8 emulator written with C and SDL2
在chip8.c里的指令集,比如250和251行,应该先比较写入VF后,再相减
因为VF是标记有没有借位,先相减后再比较,意义就完全错了
Hi, I wrote a simple chip8 emulator on a platform called lowres.nx and I'm trying to test it with your test roms. I got everything ok with test_opcode.ch8, but one error with BC_test.ch8 (Error "E05").
According to http://devernay.free.fr/hacks/chip8/C8TECH10.HTM#8xy5, this instruction is:
8xy5 - SUB Vx, Vy
Set Vx = Vx - Vy, set VF = NOT borrow.If Vx > Vy, then VF is set to 1, otherwise 0. Then Vy is subtracted from Vx, and the results stored in Vx.
So after verification it seems that my code is ok ($FF - $EF does not borrow hence VF=1 => Error).
参考: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile
在交叉编译的时候会报错.
$ make
x86_64-w64-mingw32-gcc -Wall -c -std=c11 -I/home/origami/code/sdl_learn/mingw-sdk/x86_64-w64-mingw32/include main.c -o main.o
main.c: In function ‘SDL_main’:
main.c:282:9: warning: implicit declaration of function ‘time’ [-Wimplicit-function-declaration]
282 | srand(time(0));
| ^~~~
x86_64-w64-mingw32-gcc -Wall -c -std=c11 -I/home/origami/code/sdl_learn/mingw-sdk/x86_64-w64-mingw32/include chip8.c -o chip8.o
x86_64-w64-mingw32-gcc main.o chip8.o -L/opt/local/x86_64-w64-mingw32/lib -lmingw32 -L/home/origami/code/sdl_learn/mingw-sdk/x86_64-w64-mingw32/lib -lSDL2main -lSDL2 -lSDL2_image -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc -static -o main.exe
/usr/lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld: /usr/lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libkernel32.a(dpeqbs01169.o):(.text+0x0): multiple definition of `ReadFile'; main.o:main.c:(.text+0xaf): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:25: main.exe] Error 1
使用的Makefile
# Cross build for windows from WSL.
CXX = x86_64-w64-mingw32-gcc
SDL_ROOT = /home/origami/code/sdl_learn/mingw-sdk
SDL_INCLUDE = -I$(SDL_ROOT)/x86_64-w64-mingw32/include
CXXFLAGS = -Wall -c -std=c11 $(SDL_INCLUDE)
SDL_LIB = -L$(SDL_ROOT)/x86_64-w64-mingw32/lib -lSDL2main -lSDL2 -lSDL2_image
MINGW_LIB = -L/opt/local/x86_64-w64-mingw32/lib -lmingw32
OTHER_LD_FLAGS = -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid
LDFLAGS = $(MINGW_LIB) $(SDL_LIB) $(OTHER_LD_FLAGS) -static-libgcc -static
EXE = main.exe
all: $(EXE)
$(EXE): main.o chip8.o
$(CXX) main.o chip8.o $(LDFLAGS) -o $@
main.o: main.c
$(CXX) $(CXXFLAGS) $< -o $@
chip8.o: chip8.c
$(CXX) $(CXXFLAGS) $< -o $@
clean:
rm *.o $(EXE)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.