This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ld c, LOW(rP1) | |
ld a, $20 ; Select D-pad | |
ld [$ff00+c], a | |
REPT 6 | |
ld a, [$ff00+c] | |
ENDR | |
or $F0 ; Set 4 upper bits (give them consistency) | |
ld b, a | |
; Filter impossible D-pad combinations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 1/2 | |
ld hl, wMovementVector + 3 | |
sra [hl] | |
dec l ; dec hl | |
rr [hl] | |
dec l ; dec hl | |
sra [hl] | |
dec l ; dec hl | |
rr [hl] | |
call .tryMoving |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.fadeIn | |
ld a, [wCurStateFirstFrame] | |
and a | |
jr z, .notFirstFrame | |
; Assume palettes are properly set (ie. we're fading from the proper solid colors) | |
; Perform first fade immediately | |
ld a, 1 | |
ld [wFadeFrames], a | |
; This is the value that will get added to each color | |
; It'll be decremented just below |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Here's some technical explanation about Game Boy sample playing: | |
; The "usual" way of playing sound samples on the Game Boy is to use its wave channel | |
; Basically, let that channel play its 32 4-bit samples, then refill it | |
; Problem: to refill the channel, you have to disable it then restart it | |
; However, when doing so, the "sample buffer" is set to 0 **and not updated** | |
; This means the channel outputs a spike as its first sample, creating a buzzing sound | |
; | |
; Why? That's because of how the Game Boy generates sound: each channel produces | |
; a digital value between 0 and 15, which is fed to a DAC (Digital to Analog Converter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include "link/main.h" | |
#include "link/script.h" | |
#include "link/section.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <ctype.h> | |
#include "link/main.h" | |
#include "link/script.h" | |
#include "link/section.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename Ts...> | |
char * reassembleString(Ts... ts) { | |
char * fragments[]{ts...}; | |
size_t size = 0; | |
for(size_t i = 0; i < sizeof...(Ts); i++) { | |
size += strlen(fragments[i]); | |
} | |
char * output = new char[size + 1]; | |
char * ptr = output; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jr z, .noVRAMTransfer ; This JR is out of range | |
ld c, a | |
ldh a, [hConsoleType] | |
and a | |
jr z, .GDMA | |
ld [wSP], sp | |
ldh a, [hVRAMCopySrc] | |
ld l, a | |
ldh a, [hVRAMCopySrc+1] | |
ld h, a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
push de | |
ld [wSP], sp | |
ldh a, [hVRAMCopySrc] | |
ld l, a | |
ldh a, [hVRAMCopySrc+1] | |
ld h, a | |
ld sp, hl | |
ldh a, [hVRAMCopyDest] | |
ld l, a | |
ldh a, [hVRAMCopyDest+1] |