Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions unbricked/audio/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ DEF BRICK_RIGHT EQU $06
DEF BLANK_TILE EQU $08
; ANCHOR_END: constants

SECTION "VBlank Interrupt", ROM0[$40]
VBlankInterrupt:
push af
ld a, 1
ld [wVBlankDone], a
pop af
reti

SECTION "Header", ROM0[$100]

jp EntryPoint
Expand Down Expand Up @@ -93,14 +101,14 @@ ClearOam:
ld a, 0
ld [wFrameCounter], a

ld a, IE_VBLANK
ldh [rIE], a
xor a
ldh [rIF], a
ei

Main:
ld a, [rLY]
cp 144
jp nc, Main
WaitVBlank2:
ld a, [rLY]
cp 144
jp c, WaitVBlank2
call WaitForVBlank

; Add the ball's momentum to its position in OAM.
ld a, [wBallMomentumX]
Expand Down Expand Up @@ -361,6 +369,17 @@ MemCopy:
jp nz, MemCopy
ret

WaitForVBlank:
xor a
ld [wVBlankDone], a
.wait
halt
nop
ld a, [wVBlankDone]
and a
jr z, .wait
ret

; ANCHOR: bounce-sound
PlayBounceSound:
ld a, $85
Expand Down Expand Up @@ -645,6 +664,9 @@ BallEnd:
SECTION "Counter", WRAM0
wFrameCounter: db

SECTION "VBlank Variables", WRAM0
wVBlankDone: db

SECTION "Input Variables", WRAM0
wCurKeys: db
wNewKeys: db
Expand Down
35 changes: 28 additions & 7 deletions unbricked/bcd/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ DEF SCORE_TENS EQU $9870
DEF SCORE_ONES EQU $9871
; ANCHOR_END: score-tile-location

SECTION "VBlank Interrupt", ROM0[$40]
VBlankInterrupt:
push af
ld a, 1
ld [wVBlankDone], a
pop af
reti

SECTION "Header", ROM0[$100]

jp EntryPoint
Expand Down Expand Up @@ -100,16 +108,15 @@ ClearOam:
ld [wCurKeys], a
ld [wNewKeys], a
ld [wScore], a
ld a, IE_VBLANK
ldh [rIE], a
xor a
ldh [rIF], a
ei
; ANCHOR_END: init-variables

Main:
ld a, [rLY]
cp 144
jp nc, Main
WaitVBlank2:
ld a, [rLY]
cp 144
jp c, WaitVBlank2
call WaitForVBlank

; Add the ball's momentum to its position in OAM.
ld a, [wBallMomentumX]
Expand Down Expand Up @@ -392,6 +399,17 @@ MemCopy:
jp nz, MemCopy
ret

WaitForVBlank:
xor a
ld [wVBlankDone], a
.wait
halt
nop
ld a, [wVBlankDone]
and a
jr z, .wait
ret

Tiles:
dw `33333333
dw `33333333
Expand Down Expand Up @@ -742,6 +760,9 @@ BallEnd:
SECTION "Counter", WRAM0
wFrameCounter: db

SECTION "VBlank Variables", WRAM0
wVBlankDone: db

SECTION "Input Variables", WRAM0
wCurKeys: db
wNewKeys: db
Expand Down
36 changes: 29 additions & 7 deletions unbricked/bricks/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ DEF BRICK_RIGHT EQU $06
DEF BLANK_TILE EQU $08
; ANCHOR_END: constants

SECTION "VBlank Interrupt", ROM0[$40]
VBlankInterrupt:
push af
ld a, 1
ld [wVBlankDone], a
pop af
reti

SECTION "Header", ROM0[$100]

jp EntryPoint
Expand Down Expand Up @@ -96,14 +104,14 @@ ClearOam:
ld [wCurKeys], a
ld [wNewKeys], a

ld a, IE_VBLANK
ldh [rIE], a
xor a
ldh [rIF], a
ei

Main:
ld a, [rLY]
cp 144
jp nc, Main
WaitVBlank2:
ld a, [rLY]
cp 144
jp c, WaitVBlank2
call WaitForVBlank

; Add the ball's momentum to its position in OAM.
ld a, [wBallMomentumX]
Expand Down Expand Up @@ -357,6 +365,17 @@ MemCopy:
jp nz, MemCopy
ret

WaitForVBlank:
xor a
ld [wVBlankDone], a
.wait
halt
nop
ld a, [wVBlankDone]
and a
jr z, .wait
ret

Tiles:
dw `33333333
dw `33333333
Expand Down Expand Up @@ -615,6 +634,9 @@ BallEnd:
SECTION "Counter", WRAM0
wFrameCounter: db

SECTION "VBlank Variables", WRAM0
wVBlankDone: db

SECTION "Input Variables", WRAM0
wCurKeys: db
wNewKeys: db
Expand Down
35 changes: 28 additions & 7 deletions unbricked/collision/main.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
INCLUDE "hardware.inc"

SECTION "VBlank Interrupt", ROM0[$40]
VBlankInterrupt:
push af
ld a, 1
ld [wVBlankDone], a
pop af
reti

SECTION "Header", ROM0[$100]

jp EntryPoint
Expand Down Expand Up @@ -95,16 +103,15 @@ ClearOam:
ld [wFrameCounter], a
ld [wCurKeys], a
ld [wNewKeys], a
ld a, IE_VBLANK
ldh [rIE], a
xor a
ldh [rIF], a
ei

; ANCHOR: momentum
Main:
ld a, [rLY]
cp 144
jp nc, Main
WaitVBlank2:
ld a, [rLY]
cp 144
jp c, WaitVBlank2
call WaitForVBlank

; Add the ball's momentum to its position in OAM.
ld a, [wBallMomentumX]
Expand Down Expand Up @@ -344,6 +351,17 @@ MemCopy:
jp nz, MemCopy
ret

WaitForVBlank:
xor a
ld [wVBlankDone], a
.wait
halt
nop
ld a, [wVBlankDone]
and a
jr z, .wait
ret

Tiles:
dw `33333333
dw `33333333
Expand Down Expand Up @@ -605,6 +623,9 @@ BallEnd:
SECTION "Counter", WRAM0
wFrameCounter: db

SECTION "VBlank Variables", WRAM0
wVBlankDone: db

SECTION "Input Variables", WRAM0
wCurKeys: db
wNewKeys: db
Expand Down
36 changes: 29 additions & 7 deletions unbricked/functions/main.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
INCLUDE "hardware.inc"

SECTION "VBlank Interrupt", ROM0[$40]
VBlankInterrupt:
push af
ld a, 1
ld [wVBlankDone], a
pop af
reti

SECTION "Header", ROM0[$100]

jp EntryPoint
Expand Down Expand Up @@ -72,15 +80,15 @@ ClearOam:
ld a, 0
ld [wFrameCounter], a

ld a, IE_VBLANK
ldh [rIE], a
xor a
ldh [rIF], a
ei

; ANCHOR: main
Main:
ld a, [rLY]
cp 144
jp nc, Main
WaitVBlank2:
ld a, [rLY]
cp 144
jp c, WaitVBlank2
call WaitForVBlank

ld a, [wFrameCounter]
inc a
Expand All @@ -99,6 +107,17 @@ WaitVBlank2:
jp Main
; ANCHOR_END: main

WaitForVBlank:
xor a
ld [wVBlankDone], a
.wait
halt
nop
ld a, [wVBlankDone]
and a
jr z, .wait
ret

; ANCHOR: memcpy
; Copy bytes from one area to another.
; @param de: Source
Expand Down Expand Up @@ -362,6 +381,9 @@ PaddleEnd:
SECTION "Counter", WRAM0
wFrameCounter: db

SECTION "VBlank Variables", WRAM0
wVBlankDone: db

SECTION "Input Variables", WRAM0
wCurKeys: db
wNewKeys: db
35 changes: 28 additions & 7 deletions unbricked/input/main.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
INCLUDE "hardware.inc"

SECTION "VBlank Interrupt", ROM0[$40]
VBlankInterrupt:
push af
ld a, 1
ld [wVBlankDone], a
pop af
reti

SECTION "Header", ROM0[$100]

jp EntryPoint
Expand Down Expand Up @@ -74,17 +82,16 @@ ClearOam:
ld [wFrameCounter], a
ld [wCurKeys], a
ld [wNewKeys], a
ld a, IE_VBLANK
ldh [rIE], a
xor a
ldh [rIF], a
ei
; ANCHOR_END: initialize-vars

; ANCHOR: main
Main:
ld a, [rLY]
cp 144
jp nc, Main
WaitVBlank2:
ld a, [rLY]
cp 144
jp c, WaitVBlank2
call WaitForVBlank

; Check the current keys every frame and move left or right.
call UpdateKeys
Expand Down Expand Up @@ -158,6 +165,17 @@ UpdateKeys:
ret
; ANCHOR_END: input-routine

WaitForVBlank:
xor a
ld [wVBlankDone], a
.wait
halt
nop
ld a, [wVBlankDone]
and a
jr z, .wait
ret

; ANCHOR: memcpy
; Copy bytes from one area to another.
; @param de: Source
Expand Down Expand Up @@ -421,6 +439,9 @@ PaddleEnd:
SECTION "Counter", WRAM0
wFrameCounter: db

SECTION "VBlank Variables", WRAM0
wVBlankDone: db

; ANCHOR: vars
SECTION "Input Variables", WRAM0
wCurKeys: db
Expand Down
Loading