Skip to content

Commit e7988e2

Browse files
committed
Doxygen for function documentation
1 parent e8bc7f9 commit e7988e2

File tree

7 files changed

+2565
-10
lines changed

7 files changed

+2565
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build/
2+
doc/
23
*.sav
34
*.gbc
45
*.sn*

Doxyfile

Lines changed: 2440 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
# You may need to "make clean" after modifying this.
55
USE_PRECOMPRESSED_ASSETS = true
66

7+
TOPDIR = $(CURDIR)
8+
79
OBJS = build/main.o
10+
DOCFILES = $(OBJS:.o=-s.c)
811

912
TARGET = rom.gbc
1013
SYMFILE = $(TARGET:.gbc=.sym)
@@ -38,8 +41,11 @@ all: $(TARGET)
3841

3942
$(TARGET): $(OBJS) linkfile
4043
wlalink -s linkfile rom.gbc
41-
@sed -i 's/^00//' $(SYMFILE)
4244
rgbfix -Cjv -t "ZELDA NAYRUAZ8E" -k 01 -l 0x33 -m 0x1b -r 0x02 rom.gbc
45+
46+
# Fix the symbol file so that it's readable by bgb (not just no$gmb)
47+
@sed -i 's/^00//' $(SYMFILE)
48+
4349
ifeq ($(USE_PRECOMPRESSED_ASSETS),true)
4450
@-md5sum -c ages.md5
4551
endif
@@ -141,6 +147,7 @@ build:
141147
mkdir build/rooms
142148
mkdir build/debug
143149
mkdir build/tilesets
150+
mkdir build/doc
144151

145152

146153
.PHONY: clean run force
@@ -150,7 +157,17 @@ force:
150157
make
151158

152159
clean:
153-
rm -R build/ $(TARGET)
160+
-rm -R build/ doc/ $(TARGET)
154161

155162
run: all
156163
$(GBEMU) $(TARGET) 2>/dev/null
164+
165+
# --------------------------------------------------------------
166+
# Documentation generation
167+
# --------------------------------------------------------------
168+
169+
doc: $(DOCFILES)
170+
doxygen
171+
172+
build/%-s.c: %.s | build
173+
cd build/doc/; $(TOPDIR)/tools/asm4doxy.pl ../../$<

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
rgbfix is needed)
77
* [Cygwin](http://cygwin.com/install.html) (Only required for windows users)
88

9+
## Tools needed to generate documentation
10+
11+
Type "make doc" to generate documentation.
12+
13+
* Perl
14+
* Doxygen
15+
916
# A note about compression
1017

1118
A nice bit of progress I've made is the ability to de and re-compress all of the

doxygen_index.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* \mainpage Oracle of Ages Disassembly
3+
*
4+
* \section Introduction
5+
*
6+
* Welcome to the Oracle of Ages disassembly. Hopefully this documentation will
7+
* make the code at least vaguely navigatable.
8+
*
9+
* See the "Files" section for the bulk of the documentation.
10+
*
11+
*/

main.s

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
;; The main file containing all the code in the game.
2+
;;
3+
14
.include "include/rominfo.s"
25
.include "include/defines.s"
36
.include "include/wram.s"
@@ -89,20 +92,36 @@
8992

9093
.ORGA $0068
9194

95+
;;
96+
; @addr{0068}
97+
; @param \a
98+
; @param \de
99+
;;
92100
addAToDe:
93101
add e ; $0068
94102
ld e,a ; $0069
95103
ret nc ; $006a
96104
inc d ; $006b
97105
ret ; $006c
98106

107+
;;
108+
; @addr{006d}
109+
; @param \a
110+
; @param \bc
111+
;;
99112
addAToBc:
100113
add c ; $006d
101114
ld c,a ; $006e
102115
ret nc ; $006f
103116
inc b ; $0070
104117
ret ; $0071
105118

119+
;;
120+
; Adds a*2 to de.
121+
; @addr{0072}
122+
; @param \a
123+
; @param \de
124+
;;
106125
addDoubleIndexToDe:
107126
push hl ; $0072
108127
add a ; $0073
@@ -116,6 +135,11 @@ addDoubleIndexToDe:
116135
pop hl ; $007c
117136
ret ; $007d
118137

138+
;;
139+
; Adds a*2 to bc.
140+
; @addr{007e}
141+
; @param \a
142+
; @param \bc
119143
addDoubleIndexToBc:
120144
push hl ; $007e
121145
add a ; $007f
@@ -129,6 +153,12 @@ addDoubleIndexToBc:
129153
pop hl ; $0088
130154
ret ; $0089
131155

156+
;;
157+
; Call a function in any bank, from any bank.
158+
; @addr{008a}
159+
; @param \e Bank of the function to call
160+
; @param \hl Address of the function to call
161+
;;
132162
interBankCall:
133163
ld a,($ff97) ; $008a
134164
push af ; $008d
@@ -183,6 +213,9 @@ bitTable:
183213
; Rest of the header
184214
.DSB $7 0
185215

216+
;;
217+
; The game's entrypoint.
218+
; @addr{0150}
186219
begin: ; 0150
187220
nop
188221
di
@@ -207,7 +240,11 @@ func_0169:
207240
jp $4000
208241

209242

210-
; Returns in A the number of set bits in A
243+
;; Get the number of set bits in a.
244+
; @addr{0176}
245+
; @param a Passed as register to check, returns total number of set
246+
; bits.
247+
; @param[out] b Also set to the return value.
211248
getNumSetBits: ; 0176
212249
ld b,$00 ; $0176
213250
-
@@ -220,6 +257,13 @@ getNumSetBits: ; 0176
220257
ld a,b ; $017f
221258
ret ; $0180
222259

260+
;;
261+
; Add a bcd-encoded number to a 16-bit memory address. If it would go above
262+
; $9999, the result is $9999.
263+
; @addr{0181}
264+
; @param[in] bc Number to add.
265+
; @param hl Address to add with and store result into.
266+
; @return @cflag Set if the value would have gone over $9999.
223267
addDecimalToHlRef:
224268
ld a,(hl) ; $0181
225269
add c ; $0182
@@ -235,6 +279,12 @@ addDecimalToHlRef:
235279
ldd (hl),a ; $018d
236280
ret ; $018e
237281

282+
;; Subtract a bcd-encoded number from a 16-bit memory address. If it would go
283+
;; below 0, the result is 0.
284+
; @addr{018f}
285+
; @param[in] bc Value to subtract.
286+
; @param hl Address to subtract with and store result into.
287+
; @return @cflag Set if the value would have gone under $0000.
238288
subDecimalFromHlRef: ; 018f
239289
ld a,(hl) ; $018f
240290
sub c ; $0190
@@ -251,6 +301,12 @@ subDecimalFromHlRef: ; 018f
251301
scf ; $019b
252302
ret ; $019c
253303

304+
;; Multiply A by C.
305+
; @addr{019d}
306+
; @param a Operand 1
307+
; @param[in] c Operand 2
308+
; @param[out] hl Result
309+
; \trashes{b,e}
254310
multiplyAByC: ; 019d
255311
ld e,$08 ; $019d
256312
ld b,$00 ; $019f
@@ -266,7 +322,10 @@ multiplyAByC: ; 019d
266322
jr nz,-
267323
ret ; $01ab
268324

269-
; Multiplies A by $10 and stores result in bc.
325+
;; Multiply A by $10, store result in bc.
326+
; @addr{01ac}
327+
; @param a Value to multiply
328+
; @param[out] bc Result
270329
multiplyABy0x10: ; 01ac
271330
swap a ; $01ac
272331
ld b,a ; $01ae
@@ -277,7 +336,10 @@ multiplyABy0x10: ; 01ac
277336
ld b,a ; $01b5
278337
ret ; $01b6
279338

280-
339+
;; Multiply A by 8, store result in bc.
340+
; @addr{01b7}
341+
; @param a Value to multiply
342+
; @param[out] bc Result
281343
multiplyABy8: ; 01b7
282344
swap a ; $01b7
283345
rrca ; $01b9
@@ -289,6 +351,10 @@ multiplyABy8: ; 01b7
289351
ld b,a ; $01c1
290352
ret ; $01c2
291353

354+
;; Multiply A by 4, store result in bc.
355+
; @addr{01c3}
356+
; @param a Value to multiply
357+
; @param[out] bc Result
292358
multiplyABy4: ; 01c3
293359
ld b,$00 ; $01c3
294360
add a ; $01c5
@@ -298,7 +364,10 @@ multiplyABy4: ; 01c3
298364
ld c,a ; $01cb
299365
ret ; $01cc
300366

301-
; Converts signed 8-bit value in A to signed 16-bit value in bc
367+
;; Convert a signed 8-bit value in A to signed 16-bit value in bc
368+
; @addr{01cd}
369+
; @param a Signed value
370+
; @param[out] bc Signed 16-bit value
302371
s8ToS16: ; 01cd
303372
ld b,$ff ; $01cd
304373
bit 7,a ; $01cf

tools/asm4doxy.pl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@
994994
.$func_descr
995995
."\n */\n";
996996
# Return type from doxygen comments.
997-
if ( $func_descr =~ /[\@\\]return[^\s]*\s+([\w\:\/\(\)\[\]\%]+)/io )
997+
if ( $func_descr =~ /[\@\\]return[^\s]*\s+([\w\:\/\(\)\[\]\%\\@]+)/io )
998998
{
999999
$func_return = $1;
10001000
}
@@ -1056,11 +1056,21 @@
10561056
elsif ( $func_proto eq "" )
10571057
{
10581058
$func_descr = $files_funcs_descr{$curr_file}{$func};
1059-
while ($func_descr =~ /[\@\\]param[^\s]*\s+([\w\:\/\(\)\[\]\%]+)/io)
1059+
while ($func_descr =~ /[\@\\]param([^\s]*)\s+([\w\:\/\(\)\[\]\%\\@]+)/io)
10601060
{
1061-
my $par = $1;
1061+
my $type = $1;
1062+
my $par = $2;
10621063
$par =~ s/\://go;
1063-
$func_proto .= "$par, ";
1064+
$par =~ s/^\\//go;
1065+
if ( $type eq "" )
1066+
{
1067+
$func_proto .= "$par, ";
1068+
}
1069+
else
1070+
{
1071+
$type =~ s/[\[\]]//go;
1072+
$func_proto .= "$type $par, ";
1073+
}
10641074
$func_descr =~ s/[\@\\]param//io;
10651075
}
10661076
}

0 commit comments

Comments
 (0)