diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 206521fa95c5a568913291bdd264f4d2a481aeef..daff0a9883bdb764f0ae44a17460bba4f954639a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -117,6 +117,8 @@ deploy-cloudfare-prod: - cd frontends/web/dist - cp -rp ../static/* . - npm_config_yes=true npx wrangler pages publish . --project-name=boytacean --branch prod + - npm_config_yes=true npx wrangler pages publish . --project-name=boytacean --branch production + - npm_config_yes=true npx wrangler pages publish . --project-name=boytacean --branch main dependencies: - build-wasm only: diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b9efacf3c22b98fd13f30ee5c25345c664683f..1d13c103754540620654f88272f1411a26c191f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* Support for CGB flag parsing +* ### Changed @@ -17,7 +17,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* + +## [0.7.3] - 2023-04-02 + +### Added + +* Support for CGB flag parsing +* Waveform plotting support + +### Fixed + * Major JoyPad issue with Action/Select read in register +* Small issue with channel 3 audio and DAC disable ## [0.7.2] - 2023-03-04 diff --git a/Cargo.toml b/Cargo.toml index 047f40e303f92aac10951eaab430e0bdcb659eb5..d4545741d54568cc827051d7dd1b27bca5f55d5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "boytacean" description = "A Game Boy emulator that is written in Rust." -version = "0.7.2" +version = "0.7.3" authors = ["João Magalhães <joamag@gmail.com>"] license = "Apache-2.0" repository = "https://github.com/joamag/boytacean" diff --git a/frontends/sdl/Cargo.toml b/frontends/sdl/Cargo.toml index 54e99a6d467af04c2af0b64e828e3dd494f2d598..84b693fec789f10ae15d34f1d5c055cc05cb4f80 100644 --- a/frontends/sdl/Cargo.toml +++ b/frontends/sdl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "boytacean-sdl" -version = "0.7.2" +version = "0.7.3" authors = ["João Magalhães <joamag@gmail.com>"] description = "An SDL frontend for Boytacen" license = "Apache-2.0" diff --git a/frontends/sdl/src/main.rs b/frontends/sdl/src/main.rs index 17e35639188172fbca10e2e004fd54e0db3503c7..9c6f6d0a0f0bc90136b6f4152f7a676c45200d24 100644 --- a/frontends/sdl/src/main.rs +++ b/frontends/sdl/src/main.rs @@ -451,7 +451,7 @@ fn main() { // ROM file and starts running it let mut emulator = Emulator::new(game_boy); emulator.start(SCREEN_SCALE); - emulator.load_rom(Some("../../res/roms/pocket.gb")); + emulator.load_rom(Some("../../res/roms/demo/pocket.gb")); emulator.toggle_palette(); emulator.run(); } diff --git a/frontends/web/package.json b/frontends/web/package.json index 6173072a29b33fceefa850a9e79acd79cc1da78c..f81c8651480c18100883a4f1fc0763473622f489 100644 --- a/frontends/web/package.json +++ b/frontends/web/package.json @@ -1,6 +1,6 @@ { "name": "boytacean-web", - "version": "0.7.2", + "version": "0.7.3", "description": "The web version of Boytacean", "repository": { "type": "git", @@ -19,18 +19,18 @@ "source": "index.ts", "devDependencies": { "@parcel/transformer-typescript-tsc": "^2.8.3", - "@types/react": "^18.0.28", + "@types/react": "^18.0.32", "@types/react-dom": "^18.0.11", - "@typescript-eslint/eslint-plugin": "^5.54.0", - "@typescript-eslint/parser": "^5.54.0", - "emukit": "^0.7.2", - "eslint": "^8.35.0", - "nodemon": "^2.0.21", + "@typescript-eslint/eslint-plugin": "^5.57.0", + "@typescript-eslint/parser": "^5.57.0", + "emukit": "^0.8.0", + "eslint": "^8.37.0", + "nodemon": "^2.0.22", "parcel": "^2.8.3", - "prettier": "^2.8.4", + "prettier": "^2.8.7", "process": "^0.11.10", "react": "^18.2.0", "react-dom": "^18.2.0", - "typescript": "^4.9.5" + "typescript": "^5.0.3" } } diff --git a/frontends/web/ts/gb.ts b/frontends/web/ts/gb.ts index dcde0e67798a246778a73e203c21ef4afb77f7a8..aea7ee14a496609b39255bd55554d8e8f111609b 100644 --- a/frontends/web/ts/gb.ts +++ b/frontends/web/ts/gb.ts @@ -79,7 +79,7 @@ const KEYS_NAME: Record<string, number> = { B: PadKey.B }; -const ROM_PATH = require("../../../res/roms/pocket.gb"); +const ROM_PATH = require("../../../res/roms/demo/pocket.gb"); /** * Top level class that controls the emulator behaviour @@ -606,6 +606,18 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { }; } + get audioOutput(): Record<string, number> { + const output = this.gameBoy?.audio_all_output(); + if (!output) return {}; + return { + master: output[0], + ch1: output[1], + ch2: output[2], + ch3: output[3], + ch4: 0 + }; + } + get palette(): string | undefined { const paletteObj = PALETTES[this.paletteIndex]; return paletteObj.name; diff --git a/res/roms/_headers b/res/roms/_headers deleted file mode 100644 index a292ad706e3c35f1cae544006acd43d1e72c119b..0000000000000000000000000000000000000000 --- a/res/roms/_headers +++ /dev/null @@ -1,4 +0,0 @@ - -/* - X-Robots-Tag: all - Access-Control-Allow-Origin: * diff --git a/res/roms/20y.gb b/res/roms/demo/20y.gb similarity index 100% rename from res/roms/20y.gb rename to res/roms/demo/20y.gb diff --git a/res/roms/gejmboj.gb b/res/roms/demo/gejmboj.gb similarity index 100% rename from res/roms/gejmboj.gb rename to res/roms/demo/gejmboj.gb diff --git a/res/roms/pocket.gb b/res/roms/demo/pocket.gb similarity index 100% rename from res/roms/pocket.gb rename to res/roms/demo/pocket.gb diff --git a/res/roms/opus5.gb b/res/roms/game/opus5.gb similarity index 100% rename from res/roms/opus5.gb rename to res/roms/game/opus5.gb diff --git a/res/roms/shocklobster.gb b/res/roms/game/shocklobster.gb similarity index 100% rename from res/roms/shocklobster.gb rename to res/roms/game/shocklobster.gb diff --git a/res/roms/thebouncingball.gb b/res/roms/game/thebouncingball.gb similarity index 100% rename from res/roms/thebouncingball.gb rename to res/roms/game/thebouncingball.gb diff --git a/res/roms/robots.txt b/res/roms/robots.txt deleted file mode 100644 index a78466b3d66c7386c0ccc2293a67bccf4b6c85ff..0000000000000000000000000000000000000000 --- a/res/roms/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Allow: / diff --git a/res/roms/test/blargg/cgb_sound/cgb_sound.gb b/res/roms/test/blargg/cgb_sound/cgb_sound.gb new file mode 100644 index 0000000000000000000000000000000000000000..dc50471b00315edade129fc438517975a7036465 Binary files /dev/null and b/res/roms/test/blargg/cgb_sound/cgb_sound.gb differ diff --git a/res/roms/paradius/cpu/01-special.gb b/res/roms/test/blargg/cpu/01-special.gb similarity index 100% rename from res/roms/paradius/cpu/01-special.gb rename to res/roms/test/blargg/cpu/01-special.gb diff --git a/res/roms/paradius/cpu/02-interrupts.gb b/res/roms/test/blargg/cpu/02-interrupts.gb similarity index 100% rename from res/roms/paradius/cpu/02-interrupts.gb rename to res/roms/test/blargg/cpu/02-interrupts.gb diff --git a/res/roms/paradius/cpu/03-op sp,hl.gb b/res/roms/test/blargg/cpu/03-op sp,hl.gb similarity index 100% rename from res/roms/paradius/cpu/03-op sp,hl.gb rename to res/roms/test/blargg/cpu/03-op sp,hl.gb diff --git a/res/roms/paradius/cpu/04-op r,imm.gb b/res/roms/test/blargg/cpu/04-op r,imm.gb similarity index 100% rename from res/roms/paradius/cpu/04-op r,imm.gb rename to res/roms/test/blargg/cpu/04-op r,imm.gb diff --git a/res/roms/paradius/cpu/05-op rp.gb b/res/roms/test/blargg/cpu/05-op rp.gb similarity index 100% rename from res/roms/paradius/cpu/05-op rp.gb rename to res/roms/test/blargg/cpu/05-op rp.gb diff --git a/res/roms/paradius/cpu/06-ld r,r.gb b/res/roms/test/blargg/cpu/06-ld r,r.gb similarity index 100% rename from res/roms/paradius/cpu/06-ld r,r.gb rename to res/roms/test/blargg/cpu/06-ld r,r.gb diff --git a/res/roms/paradius/cpu/07-jr,jp,call,ret,rst.gb b/res/roms/test/blargg/cpu/07-jr,jp,call,ret,rst.gb similarity index 100% rename from res/roms/paradius/cpu/07-jr,jp,call,ret,rst.gb rename to res/roms/test/blargg/cpu/07-jr,jp,call,ret,rst.gb diff --git a/res/roms/paradius/cpu/08-misc instrs.gb b/res/roms/test/blargg/cpu/08-misc instrs.gb similarity index 100% rename from res/roms/paradius/cpu/08-misc instrs.gb rename to res/roms/test/blargg/cpu/08-misc instrs.gb diff --git a/res/roms/paradius/cpu/09-op r,r.gb b/res/roms/test/blargg/cpu/09-op r,r.gb similarity index 100% rename from res/roms/paradius/cpu/09-op r,r.gb rename to res/roms/test/blargg/cpu/09-op r,r.gb diff --git a/res/roms/paradius/cpu/10-bit ops.gb b/res/roms/test/blargg/cpu/10-bit ops.gb similarity index 100% rename from res/roms/paradius/cpu/10-bit ops.gb rename to res/roms/test/blargg/cpu/10-bit ops.gb diff --git a/res/roms/paradius/cpu/11-op a,(hl).gb b/res/roms/test/blargg/cpu/11-op a,(hl).gb similarity index 100% rename from res/roms/paradius/cpu/11-op a,(hl).gb rename to res/roms/test/blargg/cpu/11-op a,(hl).gb diff --git a/res/roms/paradius/cpu/cpu_instrs.gb b/res/roms/test/blargg/cpu/cpu_instrs.gb similarity index 100% rename from res/roms/paradius/cpu/cpu_instrs.gb rename to res/roms/test/blargg/cpu/cpu_instrs.gb diff --git a/res/roms/test/blargg/dmg_sound/dmg_sound.gb b/res/roms/test/blargg/dmg_sound/dmg_sound.gb new file mode 100644 index 0000000000000000000000000000000000000000..fe9131044031c45f404642f5dc8a9ec43ecd2065 Binary files /dev/null and b/res/roms/test/blargg/dmg_sound/dmg_sound.gb differ diff --git a/res/roms/test/blargg/halt_bug/halt_bug.gb b/res/roms/test/blargg/halt_bug/halt_bug.gb new file mode 100644 index 0000000000000000000000000000000000000000..38e36625d805e68cb3b8cbf562d6dff500060bdd Binary files /dev/null and b/res/roms/test/blargg/halt_bug/halt_bug.gb differ diff --git a/res/roms/paradius/instr_timing/instr_timing.gb b/res/roms/test/blargg/instr_timing/instr_timing.gb similarity index 100% rename from res/roms/paradius/instr_timing/instr_timing.gb rename to res/roms/test/blargg/instr_timing/instr_timing.gb diff --git a/res/roms/paradius/interrupt_time/interrupt_time.gb b/res/roms/test/blargg/interrupt_time/interrupt_time.gb similarity index 100% rename from res/roms/paradius/interrupt_time/interrupt_time.gb rename to res/roms/test/blargg/interrupt_time/interrupt_time.gb diff --git a/res/roms/test/blargg/mem_timing-2/mem_timing.gb b/res/roms/test/blargg/mem_timing-2/mem_timing.gb new file mode 100644 index 0000000000000000000000000000000000000000..2665aa2d4f2b613b79eceef1a3365d238f919bb8 Binary files /dev/null and b/res/roms/test/blargg/mem_timing-2/mem_timing.gb differ diff --git a/res/roms/paradius/mem_timing/mem_timing.gb b/res/roms/test/blargg/mem_timing/mem_timing.gb similarity index 100% rename from res/roms/paradius/mem_timing/mem_timing.gb rename to res/roms/test/blargg/mem_timing/mem_timing.gb diff --git a/res/roms/paradius/oam_bug/oam_bug.gb b/res/roms/test/blargg/oam_bug/oam_bug.gb similarity index 100% rename from res/roms/paradius/oam_bug/oam_bug.gb rename to res/roms/test/blargg/oam_bug/oam_bug.gb diff --git a/res/roms/dmg_acid2.gb b/res/roms/test/dmg_acid2.gb similarity index 100% rename from res/roms/dmg_acid2.gb rename to res/roms/test/dmg_acid2.gb diff --git a/res/roms/firstwhite.gb b/res/roms/test/firstwhite.gb similarity index 100% rename from res/roms/firstwhite.gb rename to res/roms/test/firstwhite.gb diff --git a/res/roms/jayro.gb b/res/roms/test/jayro.gb similarity index 100% rename from res/roms/jayro.gb rename to res/roms/test/jayro.gb diff --git a/res/roms/rtc3test.gb b/res/roms/test/rtc3test.gb similarity index 100% rename from res/roms/rtc3test.gb rename to res/roms/test/rtc3test.gb diff --git a/res/roms/sprite_priority.gb b/res/roms/test/sprite_priority.gb similarity index 100% rename from res/roms/sprite_priority.gb rename to res/roms/test/sprite_priority.gb diff --git a/src/apu.rs b/src/apu.rs index b7f6914304700ff98e7f501e48352e63bab620c5..77a24ef925c7f379a54e5650e71ef14b923701d8 100644 --- a/src/apu.rs +++ b/src/apu.rs @@ -404,6 +404,18 @@ impl Apu { self.ch1_output + self.ch2_output + self.ch3_output + self.ch4_output } + pub fn ch1_output(&self) -> u8 { + self.ch1_output + } + + pub fn ch2_output(&self) -> u8 { + self.ch2_output + } + + pub fn ch3_output(&self) -> u8 { + self.ch3_output + } + pub fn audio_buffer(&self) -> &VecDeque<u8> { &self.audio_buffer } @@ -582,7 +594,7 @@ impl Apu { return; } - if self.ch3_enabled { + if self.ch3_enabled && self.ch3_dac { let wave_index = self.ch3_position >> 1; let mut output = self.wave_ram[wave_index as usize]; output = if (self.ch3_position & 0x01) == 0x01 { diff --git a/src/gb.rs b/src/gb.rs index 07acdf7c93fb132f6448a788f7da5acbc8189259..a45b89216b24bfbd7525fcd4892336e753b8fecc 100644 --- a/src/gb.rs +++ b/src/gb.rs @@ -189,6 +189,31 @@ impl GameBoy { buffer } + pub fn audio_output(&self) -> u8 { + self.apu_i().output() + } + + pub fn audio_all_output(&self) -> Vec<u8> { + vec![ + self.audio_output(), + self.audio_ch1_output(), + self.audio_ch2_output(), + self.audio_ch3_output(), + ] + } + + pub fn audio_ch1_output(&self) -> u8 { + self.apu_i().ch1_output() + } + + pub fn audio_ch2_output(&self) -> u8 { + self.apu_i().ch2_output() + } + + pub fn audio_ch3_output(&self) -> u8 { + self.apu_i().ch3_output() + } + pub fn cartridge_eager(&mut self) -> Cartridge { self.mmu().rom().clone() }