Skip to content
This repository was archived by the owner on Feb 24, 2022. It is now read-only.

Commit 856e8c4

Browse files
restructured project on top of ISSOtm's gb-boilerplate
1 parent 502e1c4 commit 856e8c4

22 files changed

+3972
-10
lines changed

Makefile

-5
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ endif
109109
# "Source" assets can thus be safely stored there without `make clean` removing them
110110
VPATH := $(SRCDIR)
111111

112-
# Define how to compress files using the PackBits16 codec
113-
# Compressor script requires Python 3
114-
$(RESDIR)/%.pb16: $(SRCDIR)/tools/pb16.py $(RESDIR)/%
115-
@$(MKDIR_P) $(@D)
116-
$^ $@
117112

118113
# Catch non-existent files
119114
# KEEP THIS LAST!!

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
_Why Can't I Find An Intuitive Usage For The Tiles?_
44

55
This repo is part of [HomebrewOwl.GB](https://github.com/NotImplementedLife/HomebrewOwl.GB "HomebrewOwl") projects collection.
6-
Download the latest version [here](https://github.com/NotImplementedLife/rubik/releases/download/1.2/rubik_1_2.gb)
6+
Download the latest version [here](https://github.com/NotImplementedLife/rubik/releases/download/1.3/rubik_1_3.gb).
77

88
Uh, well... So, I made a Rubik's cube simulator on Gameboy. _`Cause why not?_ Whoo ```>^•^<```
99

project.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ MBC := 0x00
3434
SRAMSIZE := 0x00
3535

3636
# ROM name
37-
ROMNAME := rubik-1.$(VERSION)
37+
ROMNAME := rubik_1_$(VERSION)
3838
ROMEXT := gb
3939

4040

src/HomebrewOwl.GB

src/brush.asm

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;--------------------------------------------------------------
2+
;--------------------------------------------------------------
3+
SECTION "Brush", ROM0
4+
;--------------------------------------------------------------
5+
6+
7+
;-Func---------------------------------------------------------
8+
refreshBshSlots_Cube0::
9+
;-----------------------------------------refreshBshSlots_Cube0
10+
ld de, CubeState
11+
ld bc, 27
12+
ld hl, BshSlots
13+
call loadMemory
14+
ret
15+
;-----------------------------------------refreshBshSlots_Cube0
16+
17+
18+
19+
20+
;--------------------------------------------------------------
21+
;--------------------------------------------------------------
22+
SECTION "Brush Patterns", ROM0
23+
;--------------------------------------------------------------
24+
25+
Brush0::
26+
DB $02, $00, $27, $00, $72, $00, $20, $00, $04, $00, $4e, $00, $e4, $00, $40, $00 ; brightest
27+
Brush1::
28+
DB $00, $00, $77, $00, $77, $00, $77, $00, $00, $00, $77, $00, $77, $00, $77, $00
29+
Brush2::
30+
DB $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00
31+
Brush3::
32+
DB $ee, $11, $dd, $22, $bb, $44, $77, $88, $ee, $11, $dd, $22, $bb, $44, $77, $88
33+
Brush4::
34+
DB $5a, $a5, $c3, $3c, $24, $db, $99, $66, $99, $66, $24, $db, $c3, $3c, $5a, $a5
35+
Brush5::
36+
DB $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff ; darkest
37+
38+
BrushSlots::
39+
DB $00, $01, $02, $03, $04, $05, $00, $01, $02, $03, $04, $05, $00, $01, $02, $03, $04, $05, $00, $01, $02, $03, $04, $05, $00, $01, $02
40+

src/cube.asm

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
SECTION "CUBE_VARS", WRAM0, ALIGN[8]
2+
CubeState::
3+
DS 54
4+
5+
CubeStateBackup::
6+
DS 54
7+
8+
SECTION "CUBE", ROM0
9+
10+
CubeState0::
11+
REPT(9)
12+
DB 0
13+
ENDR
14+
REPT(9)
15+
DB 1
16+
ENDR
17+
REPT(9)
18+
DB 2
19+
ENDR
20+
REPT(9)
21+
DB 3
22+
ENDR
23+
REPT(9)
24+
DB 4
25+
ENDR
26+
REPT(9)
27+
DB 5
28+
ENDR
29+
30+
loadCubeState0::
31+
ld hl, CubeState
32+
ld de, CubeState0
33+
ld bc, 54
34+
call loadMemory
35+
ret
36+
37+
;-Func---------------------------------------------------------
38+
copyCube0STAT::
39+
;-------------------------------------------------copyCube0STAT
40+
ld de, Cube0Tiles
41+
ld bc, Cube0TilesEnd
42+
ld hl, $8000
43+
call loadMemorySTAT
44+
45+
ld de, Cube0Tilemap
46+
ld bc, Cube0TilemapEnd
47+
ld hl, $9800
48+
call loadMemorySTAT
49+
ret
50+
;-------------------------------------------------copyCube0STAT
51+
52+
53+
54+
;-Func---------------------------------------------------------
55+
copyCube1STAT::
56+
;-------------------------------------------------copyCube1STAT
57+
ld de, Cube1Tiles
58+
ld bc, Cube1TilesEnd
59+
ld hl, $8D00
60+
call loadMemorySTAT
61+
62+
63+
ld de, Cube1Tilemap
64+
ld bc, Cube1TilemapEnd
65+
ld hl, $9C00
66+
call loadMemorySTAT
67+
ret
68+
;-------------------------------------------------copyCube1STAT
69+
70+

src/cube_data.asm

+453
Large diffs are not rendered by default.

src/header.asm

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
INCLUDE "src/include/macros.inc"
2+
13
SECTION "Header", ROM0[$100]
2-
di
4+
nop
35
jp EntryPoint
46
57
DS $150 - @, 0
@@ -8,4 +10,7 @@ SECTION "Entry point", ROM0
810

911
EntryPoint:
1012
call HbOwlSplashScreen
11-
jr @
13+
call CopyDMARoutine
14+
ei
15+
vBlankInit
16+
jp TitleScreen

src/include/macros.inc

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
INCLUDE "src/include/hardware.inc"
2+
3+
; swap([bc], [de]) [10 cyc]
4+
swapBytes: MACRO
5+
ld a, [bc]
6+
ld l, a
7+
ld a, [de]
8+
ld [bc], a
9+
ld a, l
10+
ld [de], a
11+
ENDM
12+
13+
; \1 = shadow sprites address
14+
initOAM: MACRO
15+
ld a, HIGH( \1 )
16+
call hOAMDMA
17+
ENDM
18+
19+
vBlankInit: MACRO
20+
xor a
21+
ldh [hVBlankFlag], a
22+
ld a, 1
23+
ld [rIE], a
24+
ENDM
25+
26+
wait_vram: MACRO
27+
.waitVRAM\@
28+
ldh a, [rSTAT]
29+
and STATF_BUSY
30+
jr nz, .waitVRAM\@
31+
ENDM
32+
33+

src/main.asm

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
INCLUDE "src/include/macros.inc"
2+
3+
SECTION "Main", ROM0
4+
5+
;-Entry--------------------------------------------------------
6+
Start::
7+
;---------------------------------------------------------Start
8+
9+
call waitForVBlank
10+
ld a, %10010001
11+
ld [rLCDC], a
12+
ld [rOBP0], a
13+
ld a, $00
14+
ld [rOBP1], a
15+
16+
call copyCube0STAT
17+
call copyCube1STAT
18+
19+
;call loadCubeState0
20+
;call refreshBshSlots_Cube0
21+
call PaintTiles0
22+
23+
call waitForVBlank
24+
ld a, %11100100
25+
ld [rBGP], a
26+
27+
initOAM SpritesData
28+
29+
ld a, [rLCDC]
30+
or LCDCF_OBJON
31+
ldh [rLCDC], a
32+
33+
call hideRotations
34+
35+
.loop
36+
call waitForVBlank
37+
call updateJoypadState
38+
call ProcessInput
39+
jr .loop
40+
;---------------------------------------------------------Start
41+
42+
;-Entry--------------------------------------------------------
43+
Pause:
44+
;---------------------------------------------------------Pause
45+
call PauseMenuInit
46+
ld hl, SpritesData
47+
ld de, PauseMenuData
48+
ld bc, 160
49+
call loadMemory
50+
call waitForVBlank
51+
initOAM SpritesData
52+
.loop
53+
call waitForVBlank
54+
call updateJoypadState
55+
ld a, [wJoypadPressed]
56+
and a, PADF_DOWN
57+
call nz, PauseMenuDown
58+
ld a, [wJoypadPressed]
59+
and a, PADF_UP
60+
call nz, PauseMenuUp
61+
62+
ld a, [wJoypadPressed]
63+
and a, PADF_B
64+
jr nz, .justLeavePauseMenu
65+
66+
ld a, [wJoypadPressed]
67+
and a, PADF_A
68+
jr z, .loop
69+
70+
ld hl, SpritesData
71+
ld de, ArrowsData
72+
ld bc, 160
73+
call loadMemory
74+
call waitForVBlank
75+
initOAM SpritesData
76+
call hideRotations
77+
78+
ld a, [pmCrtSelected]
79+
cp 2
80+
jp z, TitleScreen
81+
cp 1
82+
jp nz, Start.loop
83+
84+
; Restore backup
85+
ld hl, CubeState
86+
ld de, CubeStateBackup
87+
ld bc, 54
88+
call loadMemory
89+
90+
call refreshBshSlots_Cube0
91+
call PaintTiles0
92+
93+
jp Start.loop
94+
95+
.justLeavePauseMenu
96+
;restore sprites
97+
ld hl, SpritesData
98+
ld de, ArrowsData
99+
ld bc, 160
100+
call loadMemory
101+
call waitForVBlank
102+
initOAM SpritesData
103+
call hideRotations
104+
105+
jp Start.loop
106+
107+
108+
;---------------------------------------------------------Pause
109+
110+
;-Func--------------------------------------------------------
111+
ProcessInput:
112+
;-------------------------------------------------ProcessInput
113+
ld a, [wJoypadPressed]
114+
and a, PADF_SELECT
115+
116+
call nz, nextRotDir
117+
118+
ld a, [wJoypadPressed]
119+
and a, PADF_B
120+
call nz, disableRot
121+
122+
ld a, [wJoypadPressed]
123+
and a, PADF_LEFT
124+
call nz, handleLeftPressed
125+
126+
ld a, [wJoypadPressed]
127+
and a, PADF_RIGHT
128+
call nz, handleRightPressed
129+
130+
ld a, [wJoypadPressed]
131+
and a, PADF_START
132+
133+
jr nz, .launchPause
134+
ret
135+
.launchPause
136+
pop bc ; immitate ret without exiting function
137+
xor a
138+
ld [rotActive], a ; disable hard rotations
139+
jp Pause ; leave function, but jump execute pause menu logic
140+
;-------------------------------------------------ProcessInput

0 commit comments

Comments
 (0)