GithubHelp home page GithubHelp logo

irdcat / wasm-invaders Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 194 KB

Space invaders arcade machine emulator (intel8080 cpu & peripherials) compiled to WebAssembly

Home Page: https://irdcat.github.io/wasm-invaders/

License: MIT License

C++ 90.52% CMake 1.63% PowerShell 0.66% HTML 4.61% JavaScript 2.01% Shell 0.50% CSS 0.07%
arcade-machine emulator intel8080 wasm webassembly cpp cpp17 emscripten javascript

wasm-invaders's Introduction

Top Langs

wasm-invaders's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gmh5225

wasm-invaders's Issues

TEST8080.COM fails during testing SBI instruction

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

Implement ability to import/export hi-score data

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:

  • To import hi-score, value should be stored at address 1BF4.
  • To export hi-score, value should be taken from 20F4.

DAA instruction does not work properly

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"

DAA instruction works improperly when both flags are set

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"

Exception is thrown after pushing SDL_QUIT event to the event queue.

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)

Cpu incorrectly jumps to address 0xDC18

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

Find workaround for broken sound effects

Workaround have to be found for following problems:

  • Explosion after player dies is played twice
  • Shooting sound is played two or even three times depending on how long projectile is in the air
  • Original hardware seemed to allow overlapping of ufo flying sound to a certain extent

It probably has something to do how original hardware handled specific sounds.

CPI 0 instruction in TEST8080.COM does not reset Carry flag.

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 is stuck in the loop of the ClearScreen procedure

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.