Save 20 bytes in the CGB boot ROM
This commit is contained in:
parent
a0c5baecd8
commit
8386aaf12f
@ -103,10 +103,11 @@ Start:
|
|||||||
; Load Tilemap
|
; Load Tilemap
|
||||||
ld hl, $98C2
|
ld hl, $98C2
|
||||||
ld b, 3
|
ld b, 3
|
||||||
ld a, 8
|
|
||||||
IF DEF(FAST)
|
IF DEF(FAST)
|
||||||
xor a
|
xor a
|
||||||
ldh [$4F], a
|
ldh [$4F], a
|
||||||
|
ELSE
|
||||||
|
ld a, 8
|
||||||
ENDC
|
ENDC
|
||||||
|
|
||||||
.tilemapLoop
|
.tilemapLoop
|
||||||
@ -120,8 +121,7 @@ IF !DEF(FAST)
|
|||||||
; Switch to second VRAM Bank
|
; Switch to second VRAM Bank
|
||||||
ld a, 1
|
ld a, 1
|
||||||
ldh [$4F], a
|
ldh [$4F], a
|
||||||
ld a, 8
|
ld [hl], 8
|
||||||
ld [hl], a
|
|
||||||
; Switch to back first VRAM Bank
|
; Switch to back first VRAM Bank
|
||||||
xor a
|
xor a
|
||||||
ldh [$4F], a
|
ldh [$4F], a
|
||||||
@ -628,6 +628,8 @@ ClearMemoryPage:
|
|||||||
jr z, ClearMemoryPage
|
jr z, ClearMemoryPage
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
ReadTwoTileLines:
|
||||||
|
call ReadTileLine
|
||||||
; c = $f0 for even lines, $f for odd lines.
|
; c = $f0 for even lines, $f for odd lines.
|
||||||
ReadTileLine:
|
ReadTileLine:
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
@ -647,34 +649,28 @@ ReadTileLine:
|
|||||||
.dontSwap
|
.dontSwap
|
||||||
inc hl
|
inc hl
|
||||||
ldi [hl], a
|
ldi [hl], a
|
||||||
|
swap c
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
ReadCGBLogoHalfTile:
|
ReadCGBLogoHalfTile:
|
||||||
ld c, $f0
|
call .do_twice
|
||||||
call ReadTileLine
|
.do_twice
|
||||||
ld c, $f
|
call ReadTwoTileLines
|
||||||
call ReadTileLine
|
|
||||||
inc e
|
|
||||||
ld c, $f0
|
|
||||||
call ReadTileLine
|
|
||||||
ld c, $f
|
|
||||||
call ReadTileLine
|
|
||||||
inc e
|
inc e
|
||||||
|
ld a, e
|
||||||
ret
|
ret
|
||||||
|
|
||||||
ReadCGBLogoTile:
|
ReadCGBLogoTile:
|
||||||
|
ld c, $f0
|
||||||
call ReadCGBLogoHalfTile
|
call ReadCGBLogoHalfTile
|
||||||
ld a, e
|
|
||||||
add a, 22
|
add a, 22
|
||||||
ld e, a
|
ld e, a
|
||||||
call ReadCGBLogoHalfTile
|
call ReadCGBLogoHalfTile
|
||||||
ld a, e
|
|
||||||
sub a, 22
|
sub a, 22
|
||||||
ld e, a
|
ld e, a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
ReadTrademarkSymbol:
|
ReadTrademarkSymbol:
|
||||||
ld de, TrademarkSymbol
|
ld de, TrademarkSymbol
|
||||||
ld c,$08
|
ld c,$08
|
||||||
@ -706,19 +702,23 @@ LoadPalettes:
|
|||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
DoIntroAnimation:
|
||||||
AdvanceIntroAnimation:
|
; Animate the intro
|
||||||
|
ld a, 1
|
||||||
|
ldh [$4F], a
|
||||||
|
ld d, 26
|
||||||
|
.animationLoop
|
||||||
|
ld b, 2
|
||||||
|
call WaitBFrames
|
||||||
ld hl, $98C0
|
ld hl, $98C0
|
||||||
ld c, 3 ; Row count
|
ld c, 3 ; Row count
|
||||||
.loop
|
.loop
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
cp $F ; Already blue
|
cp $F ; Already blue
|
||||||
jr z, .nextTile
|
jr z, .nextTile
|
||||||
inc a
|
inc [hl]
|
||||||
ld [hl], a
|
|
||||||
and $7
|
and $7
|
||||||
cp $1 ; Changed a white tile, go to next line
|
jr z, .nextLine ; Changed a white tile, go to next line
|
||||||
jr z, .nextLine
|
|
||||||
.nextTile
|
.nextTile
|
||||||
inc hl
|
inc hl
|
||||||
jr .loop
|
jr .loop
|
||||||
@ -728,18 +728,7 @@ AdvanceIntroAnimation:
|
|||||||
ld l, a
|
ld l, a
|
||||||
inc hl
|
inc hl
|
||||||
dec c
|
dec c
|
||||||
ret z
|
jr nz, .loop
|
||||||
jr .loop
|
|
||||||
|
|
||||||
DoIntroAnimation:
|
|
||||||
; Animate the intro
|
|
||||||
ld a, 1
|
|
||||||
ldh [$4F], a
|
|
||||||
ld d, 26
|
|
||||||
.animationLoop
|
|
||||||
ld b, 2
|
|
||||||
call WaitBFrames
|
|
||||||
call AdvanceIntroAnimation
|
|
||||||
dec d
|
dec d
|
||||||
jr nz, .animationLoop
|
jr nz, .animationLoop
|
||||||
ret
|
ret
|
||||||
@ -796,7 +785,7 @@ ENDC
|
|||||||
.emulateDMGForCGBGame
|
.emulateDMGForCGBGame
|
||||||
call EmulateDMG
|
call EmulateDMG
|
||||||
ldh [$4C], a
|
ldh [$4C], a
|
||||||
ld a, $1;
|
ld a, $1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
EmulateDMG:
|
EmulateDMG:
|
||||||
@ -833,7 +822,7 @@ GetPaletteIndex:
|
|||||||
ld a, [hl] ; Old Licensee
|
ld a, [hl] ; Old Licensee
|
||||||
cp $33
|
cp $33
|
||||||
jr z, .newLicensee
|
jr z, .newLicensee
|
||||||
cp 1 ; Nintendo
|
dec a ; 1 = Nintendo
|
||||||
jr nz, .notNintendo
|
jr nz, .notNintendo
|
||||||
jr .doChecksum
|
jr .doChecksum
|
||||||
.newLicensee
|
.newLicensee
|
||||||
@ -848,22 +837,22 @@ GetPaletteIndex:
|
|||||||
.doChecksum
|
.doChecksum
|
||||||
ld l, $34
|
ld l, $34
|
||||||
ld c, $10
|
ld c, $10
|
||||||
ld b, 0
|
xor a
|
||||||
|
|
||||||
.checksumLoop
|
.checksumLoop
|
||||||
ld a, [hli]
|
add [hl]
|
||||||
add b
|
inc l
|
||||||
ld b, a
|
|
||||||
dec c
|
dec c
|
||||||
jr nz, .checksumLoop
|
jr nz, .checksumLoop
|
||||||
|
ld b, a
|
||||||
|
|
||||||
; c = 0
|
; c = 0
|
||||||
ld hl, TitleChecksums
|
ld hl, TitleChecksums
|
||||||
|
|
||||||
.searchLoop
|
.searchLoop
|
||||||
ld a, l
|
ld a, l
|
||||||
cp ChecksumsEnd & $FF
|
sub LOW(ChecksumsEnd) ; use sub to zero out a
|
||||||
jr z, .notNintendo
|
ret z
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
cp b
|
cp b
|
||||||
jr nz, .searchLoop
|
jr nz, .searchLoop
|
||||||
|
Loading…
Reference in New Issue
Block a user