irdcat / wasm-invaders Goto Github PK
View Code? Open in Web Editor NEWSpace invaders arcade machine emulator (intel8080 cpu & peripherials) compiled to WebAssembly
Home Page: https://irdcat.github.io/wasm-invaders/
License: MIT License
Space invaders arcade machine emulator (intel8080 cpu & peripherials) compiled to WebAssembly
Home Page: https://irdcat.github.io/wasm-invaders/
License: MIT License
PC: 026A AF: F056 BC: 0009 DE: 0000 HL: 0000 SP: 07BD Flags: { C: 0 P: 1 AC: 1 Z: 1 S: 0} Cycles: 545
SBI F1
PC: 026C AF: FF86 BC: 0009 DE: 0000 HL: 0000 SP: 07BD Flags: { C: 0 P: 1 AC: 0 Z: 0 S: 1} Cycles: 552
SBI E
PC: 026E AF: F193 BC: 0009 DE: 0000 HL: 0000 SP: 07BD Flags: { C: 1 P: 0 AC: 1 Z: 0 S: 1} Cycles: 559
CPI F0
PC: 0270 AF: F112 BC: 0009 DE: 0000 HL: 0000 SP: 07BD Flags: { C: 0 P: 0 AC: 1 Z: 0 S: 0} Cycles: 566
JZ 276
PC: 0273 AF: F112 BC: 0009 DE: 0000 HL: 0000 SP: 07BD Flags: { C: 0 P: 0 AC: 1 Z: 0 S: 0} Cycles: 576
ASM code:
SBII: SBI 0F1H ;A=F0H-0F1H-CARRY(0)=FFH,C=1
SBI 00EH ;A=FFH-OEH-CARRY(1)=F0H,C=0
CPI 0F0H
JZ ANII ;TEST "SBI"
CALL CPUER
Hi-score made during run instance of an emulator are stored in RAM at address 20F4.
Before drawing status bar, game copies existing hi-score from address 1BF4.
So functionality should work in that way:
PC: 05B3 AF: 5556 BC: FFFF DE: 3333 HL: DDDD SP: 07BD Flags: { C: 0 P: 1 AC: 1 Z: 1 S: 0} Cycles: 4622
ORA A
PC: 05B4 AF: 5506 BC: FFFF DE: 3333 HL: DDDD SP: 07BD Flags: { C: 0 P: 1 AC: 0 Z: 0 S: 0} Cycles: 4633
ORA A should add 4 cycles instead of 11.
Rather than throwing exception, display message inside document
Main loop seems to go without problems, however there's nothing on the screen.
PC: 05B4 AF: 5506 BC: FFFF DE: 3333 HL: DDDD SP: 07BD Flags: { C: 0 P: 1 AC: 0 Z: 0 S: 0} Cycles: 4633
DAA
PC: 05B5 AF: 0046 BC: FFFF DE: 3333 HL: DDDD SP: 07BD Flags: { C: 0 P: 1 AC: 0 Z: 1 S: 0} Cycles: 4637
CPI 55
PC: 05B7 AF: 0083 BC: FFFF DE: 3333 HL: DDDD SP: 07BD Flags: { C: 1 P: 0 AC: 0 Z: 0 S: 1} Cycles: 4644
ASM code:
DAA
CPI 055H
CNZ CPUER ;TEST "DAA"
PC: 05BD AF: 1013 BC: FFFF DE: 3333 HL: DDDD SP: 07BD Flags: { C: 1 P: 0 AC: 1 Z: 0 S: 0} Cycles: 3854
DAA
PC: 05BE AF: 7707 BC: FFFF DE: 3333 HL: DDDD SP: 07BD Flags: { C: 1 P: 1 AC: 0 Z: 0 S: 0} Cycles: 3858
CPI 76
PC: 05C0 AF: 7712 BC: FFFF DE: 3333 HL: DDDD SP: 07BD Flags: { C: 0 P: 0 AC: 1 Z: 0 S: 0} Cycles: 3865
CNZ 6A0
PC: 06A0 AF: 7712 BC: FFFF DE: 3333 HL: DDDD SP: 07BB Flags: { C: 0 P: 0 AC: 1 Z: 0 S: 0} Cycles: 3882
ASM code
DAA
CPI 076H
CNZ CPUER ;TEST "DAA"
Following exception can be found in the browser console.
Uncaught TypeError: Cannot read properties of undefined (reading 'deleteTexture')
at _emscripten_glDeleteTextures (wasm-invaders.js:6202:15)
at imports.<computed> (wasm-invaders.js:8814:35)
at GLES2_DestroyTexture (wasm-invaders.wasm:0x11cc16)
at SDL_DestroyTexture (wasm-invaders.wasm:0x109922)
at decltype(std::declval<void (*&)(SDL_Texture*)>()(std::declval<SDL_Texture*>())) std::__2::__invoke[abi:v15006]<void (*&)(SDL_Texture*), SDL_Texture*>(void (*&)(SDL_Texture*), SDL_Texture*&&) (wasm-invaders.wasm:0x70942)
at void std::__2::__invoke_void_return_wrapper<void, true>::__call<void (*&)(SDL_Texture*), SDL_Texture*>(void (*&)(SDL_Texture*), SDL_Texture*&&) (wasm-invaders.wasm:0x70757)
at std::__2::__function::__alloc_func<void (*)(SDL_Texture*), std::__2::allocator<void (*)(SDL_Texture*)>, void (SDL_Texture*)>::operator()[abi:v15006](SDL_Texture*&&) (wasm-invaders.wasm:0x6eae5)
at std::__2::__function::__func<void (*)(SDL_Texture*), std::__2::allocator<void (*)(SDL_Texture*)>, void (SDL_Texture*)>::operator()(SDL_Texture*&&) (wasm-invaders.wasm:0x6e912)
at std::__2::__function::__value_func<void (SDL_Texture*)>::operator()[abi:v15006](SDL_Texture*&&) const (wasm-invaders.wasm:0x4df17)
at std::__2::function<void (SDL_Texture*)>::operator()(SDL_Texture*) const (wasm-invaders.wasm:0x4da58)
Instead it should jump back to 0x18DC to CALL DrawStatus subroutine
init:
LD SP,$2400 ; Set stack pointer just below screen
LD B,$00 ; Count 256 bytes
CALL $01E6 ; Copy ROM to RAM
CALL DrawStatus ; Print scores and credits
Workaround have to be found for following problems:
It probably has something to do how original hardware handled specific sounds.
According to the execution log, carry flag is not reset after executing CPI 0
.
// State before execution
PC: 0237 AF: F597 BC: 0009 DE: 0000 HL: 0000 SP: 07BD Flags: { C: 1 P: 1 AC: 1 Z: 0 S: 1} Cycles: 402
CPI 0
// State after execution
PC: 0239 AF: F587 BC: 0009 DE: 0000 HL: 0000 SP: 07BD Flags: { C: 1 P: 1 AC: 0 Z: 0 S: 1} Cycles: 409
ASM code fragment:
;
;TEST ACCUMULATOR IMMEDIATE INSTRUCTIONS
;
AIMM: CPI 0 ;A=F5H,C=0,Z=0
JC CPIE ;TEST "CPI" FOR RE-SET CARRY
JZ CPIE ;TEST "CPI" FOR RE-SET ZERO
CPI 0F5H ;A=F5H,C=0,Z=1
JC CPIE ;TEST "CPI" FOR RE-SET CARRY ("ADI")
JNZ CPIE ;TEST "CPI" FOR RE-SET ZERO
CPI 0FFH ;A=F5H,C=1,Z=0
JZ CPIE ;TEST "CPI" FOR RE-SET ZERO
JC ACII ;TEST "CPI" FOR SET CARRY
CPIE: CALL CPUER
Cpu seems to be stuck in the procedure
ClearScreen:
LD HL,$2400 ; Screen coordinate
LD (HL),$00 ; Clear it
INC HL ; Next byte
LD A,H ; Have we done ...
CP $40 ; ... all the screen?
JP NZ,$1A5F ; No ... keep going
RET ; Out
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.