Skip to content

Commit ada8e5f

Browse files
authored
Fixed screen blanking to no longer wipe all of graphics (#266)
* Set ups a nice breakpoint function for debugging. * Fixes Screen wiping wiping all of our graphics in memory, including our internal stuff like our palettes. Links Awakening DX Works again! 😄 🎉 <img width="727" alt="screen shot 2019-02-23 at 3 30 14 am" src="https://user-images.githubusercontent.com/1448289/53285894-5c147500-371b-11e9-808c-e92b60f936d0.png">
1 parent 1de7031 commit ada8e5f

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

core/debug/breakpoints.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ export class Breakpoints {
66
static reachedBreakpoint: boolean = false;
77
}
88

9+
export function breakpoint(): void {
10+
Breakpoints.reachedBreakpoint = true;
11+
}
12+
913
export function setProgramCounterBreakpoint(breakpoint: i32): void {
1014
Breakpoints.programCounter = breakpoint;
1115
}

core/graphics/lcd.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { eightBitStoreIntoGBMemory } from '../memory/store';
66
import { updateHblankHdma } from '../memory/index';
77
import { requestLcdInterrupt, requestVBlankInterrupt } from '../interrupts/index';
88
import { checkBitOnByte, setBitOnByte, resetBitOnByte, hexLog } from '../helpers/index';
9-
import { GRAPHICS_OUTPUT_LOCATION, GRAPHICS_OUTPUT_SIZE } from '../constants';
9+
import { FRAME_LOCATION, FRAME_SIZE } from '../constants';
1010

1111
export class Lcd {
1212
// Memory Locations
@@ -102,8 +102,8 @@ function resetLcd(shouldBlankScreen: boolean): void {
102102

103103
// Blank the screen
104104
if (shouldBlankScreen) {
105-
for (let i = 0; i < GRAPHICS_OUTPUT_SIZE; i++) {
106-
store<u8>(GRAPHICS_OUTPUT_LOCATION + i, 255);
105+
for (let i = 0; i < FRAME_SIZE; i++) {
106+
store<u8>(FRAME_LOCATION + i, 255);
107107
}
108108
}
109109
}

core/graphics/palette.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GBC_PALETTE_LOCATION } from '../constants';
22
import { Cpu } from '../cpu/index';
33
import { Memory, eightBitLoadFromGBMemory, eightBitStoreIntoGBMemory } from '../memory/index';
4+
import { breakpoint } from '../debug/breakpoints';
45
import { checkBitOnByte, resetBitOnByte, setBitOnByte, concatenateBytes, hexLog } from '../helpers/index';
56

67
import { Colors } from './colors';

demo/debugger/components/graphics/paletteViewer/paletteViewer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default class PaletteViewer extends Component {
8181
}
8282

8383
update() {
84-
if (!WasmBoy.isPlaying()) {
84+
if (!WasmBoy.isReady()) {
8585
return;
8686
}
8787

@@ -147,7 +147,6 @@ export default class PaletteViewer extends Component {
147147
}
148148

149149
updateColor() {
150-
// TODO:
151150
const updateTask = async () => {
152151
// Get the CGB palette memory
153152
const memoryStart = await WasmBoy._getWasmConstant('GBC_PALETTE_LOCATION');

dist/core/core.untouched.wasm

21 Bytes
Binary file not shown.

dist/core/core.untouched.wast

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
(global $core/graphics/colors/Colors.obj1LightGrey (mut i32) (i32.const 0))
8888
(global $core/graphics/colors/Colors.obj1DarkGrey (mut i32) (i32.const 0))
8989
(global $core/graphics/colors/Colors.obj1Black (mut i32) (i32.const 0))
90+
(global $core/debug/breakpoints/Breakpoints.programCounter (mut i32) (i32.const -1))
91+
(global $core/debug/breakpoints/Breakpoints.readGbMemory (mut i32) (i32.const -1))
92+
(global $core/debug/breakpoints/Breakpoints.writeGbMemory (mut i32) (i32.const -1))
93+
(global $core/debug/breakpoints/Breakpoints.reachedBreakpoint (mut i32) (i32.const 0))
9094
(global $core/graphics/palette/Palette.memoryLocationBackgroundPaletteIndex (mut i32) (i32.const 65384))
9195
(global $core/graphics/palette/Palette.memoryLocationBackgroundPaletteData (mut i32) (i32.const 65385))
9296
(global $core/graphics/palette/Palette.memoryLocationSpritePaletteData (mut i32) (i32.const 65387))
@@ -234,10 +238,6 @@
234238
(global $core/joypad/joypad/Joypad.joypadRegisterFlipped (mut i32) (i32.const 0))
235239
(global $core/joypad/joypad/Joypad.isDpadType (mut i32) (i32.const 0))
236240
(global $core/joypad/joypad/Joypad.isButtonType (mut i32) (i32.const 0))
237-
(global $core/debug/breakpoints/Breakpoints.programCounter (mut i32) (i32.const -1))
238-
(global $core/debug/breakpoints/Breakpoints.readGbMemory (mut i32) (i32.const -1))
239-
(global $core/debug/breakpoints/Breakpoints.writeGbMemory (mut i32) (i32.const -1))
240-
(global $core/debug/breakpoints/Breakpoints.reachedBreakpoint (mut i32) (i32.const 0))
241241
(global $core/graphics/lcd/Lcd.currentLcdMode (mut i32) (i32.const 0))
242242
(global $core/graphics/lcd/Lcd.coincidenceCompare (mut i32) (i32.const 0))
243243
(global $core/graphics/lcd/Lcd.enabled (mut i32) (i32.const 1))
@@ -2581,11 +2581,11 @@
25812581
local.set $0
25822582
loop $repeat|0
25832583
local.get $0
2584-
i32.const 476288
2584+
i32.const 93184
25852585
i32.ge_s
25862586
br_if $break|0
25872587
local.get $0
2588-
i32.const 67584
2588+
i32.const 91264
25892589
i32.add
25902590
i32.const 255
25912591
i32.store8

0 commit comments

Comments
 (0)