new intro, louder sounds

This commit is contained in:
2019-01-11 00:13:47 +01:00
parent 7a0c351b12
commit 88956f2779
10 changed files with 299 additions and 200 deletions

View File

@@ -21,46 +21,27 @@ BitsSet:
db 4; 15 = 1111
EXPORT DefaultMap
SECTION "Default Map", ROM0
SECTION "Default Map", ROM0, ALIGN[8]
DefaultMap:
; 20x18 map with a 3-step pulsar in the middle
;db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 5, 0,10,10, 0, 0, 5, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 1,12, 6, 2,12, 4, 1, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 0,12, 4, 0,12, 4, 0, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 5, 0,10,10, 0, 0, 5, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0
;db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
EXPORT BackgroundTiles, BackgroundTilesEnd
SECTION "Graphics", ROM0

View File

@@ -237,7 +237,7 @@ ToggleCell:
.noise
xor a
ldh [rNR41], a ; sound length
ld a, $F1
ld a, $F2
ldh [rNR42], a ; init volume + envelope sweep
ld a, $82
ldh [rNR43], a ; frequency
@@ -251,7 +251,7 @@ ToggleCell:
ldh [rNR10], a ; sweep
ld a, (%01 << 6) + 30
ldh [rNR11], a ; pattern + sound length
ld a, $43
ld a, $F1
ldh [rNR12], a ; init volume + envelope sweep
FREQUENCY = 100
ld a, LOW(PULSE_FREQUENCY)

171
Code/intro.asm Normal file
View File

@@ -0,0 +1,171 @@
INCLUDE "hardware.inc"
INCLUDE "utils.inc"
EXPORT Random, RandomEnd
SECTION "Random", ROM0, ALIGN[4]
Random:
db -1, 1, 2, -1, 2, 0, -2, -1, -2, 3, -1, -2, 2
RandomEnd:
EXPORT Intro
SECTION "Intro", ROM0
; unpack routine from bootrom
; adapted to run even with LCD on
GraphicA:
ld c, a
GraphicB:
ld b, 4
.loop:
push bc
rl c
rla
pop bc
rl c
rla
dec b
jr nz, .loop
ld b, a
.waitVRAM
ldh a, [rSTAT]
and a, STATF_BUSY
jr nz, .waitVRAM
ld a, b
ld [hl+], a
inc hl
ld [hl+], a
inc hl
ret
Intro:
; fade bg palette
ld b, 8
.fadeDelay0
HaltAndClearInterrupts
dec b
jr nz, .fadeDelay0
ld a, %11111100
ldh [rBGP], a
ld b, 8
.fadeDelay1
HaltAndClearInterrupts
dec b
jr nz, .fadeDelay1
ld a, %11111000
ldh [rBGP], a
ld b, 8
.fadeDelay2
HaltAndClearInterrupts
dec b
jr nz, .fadeDelay2
; load bg and obj palette [0=black, 1=dark gray, 2=light gray, 3=white]
ld a, %11100100
ldh [rBGP], a
; copy nintendo logo tiles from rom to block 1
; borrowed from boot rom
ld de, NINTENDOLOGO_ROM
ld hl, _VRAM + $810
.logoloop
ld a, [de]
call GraphicA
call GraphicB
inc de
ld a, e
cp $34
jr nz, .logoloop
; move all map indices to block 1
ld hl, _SCRN0
ld bc, 18 * 32
.copy
ldh a, [rSTAT]
and a, STATF_BUSY
jr nz, .copy
ld a, [hl]
add a, $80
ld [hl+], a
dec bc
ld a, b
or c
jr nz, .copy
; display nintendo logo from new map
ld a, LCDCF_ON | LCDCF_BGON | LCDCF_BG9800
ldh [rLCDC], a
; sound
ld a, $77
ldh [rNR10], a ; sweep
ld a, (%00 << 6) + 0
ldh [rNR11], a ; pattern + sound length
ld a, $F6
ldh [rNR42], a ; set volume with long sweep
FREQUENCY = 146
ld a, LOW(PULSE_FREQUENCY)
ldh [rNR13], a
ld a, SOUND_START | HIGH(PULSE_FREQUENCY)
ldh [rNR14], a
; slowly copy default map to v-ram column by column
ld hl, DefaultMap
ld de, _SCRN0
ld b, 20
.loopX
ld c, 2
HaltAndClearInterrupts
HaltAndClearInterrupts
HaltAndClearInterrupts
.loopY
; copy 8 tiles (that's how many there is before L and E overflow)
REPT 8
ld a, [hl]
ld [de], a
ld a, l
add a, $20
ld l, a
ld a, e
add a, $20
ld e, a
ENDR
; L and E overflowed, we can increment H and L
inc h
inc d
dec c
jr nz, .loopY
; copy last 2 tiles
REPT 2
ld a, [hl]
ld [de], a
ld a, l
add a, $20
ld l, a
ld a, e
add a, $20
ld e, a
ENDR
; back to beginning (high byte)
ld a, h
sub a, 2
ld h, a
ld a, d
sub a, 2
ld d, a
; back to beginning + next column (low byte)
ld a, l
sub a, $3F
ld l, a
ld a, e
sub a, $3F
ld e, a
dec b
jp nz, .loopX
ret

View File

@@ -45,7 +45,7 @@ FREQUENCY = 330
ldh [rNR10], a ; sweep
ld a, (%01 << 6) + 30
ldh [rNR11], a ; pattern + sound length
ld a, $43
ld a, $F1
ldh [rNR12], a ; init volume + envelope sweep
ld a, l
ldh [rNR13], a
@@ -70,9 +70,6 @@ FREQUENCY = 330
SECTION "Main", ROM0[$150]
Start:
; save gameboy type in B
ld b, a
; enable sound
ld a, $80
ld [rNR52], a ; sound ON
@@ -85,49 +82,62 @@ Start:
ld a, IEF_VBLANK
ld [rIE], a
xor a
ldh [rIF], a
;IF !DEF(DIRECT_TO_GAME)
; ; skip if running on GBC or GBA
; ld a, b
; cp a, $11
; jr z, .skip
;
; call ScrollNintendoOut
;
;.skip
;ENDC
; disable screen
halt
xor a
ldh [rLCDC], a
; load bg and obj palette [0=black, 1=dark gray, 2=light gray, 3=white]
ld a, %11100100
ldh [rBGP], a
ldh [rOBP0], a
HaltAndClearInterrupts
; load 18 tiles
; 0..15: 2x2 cell combinations
; 16: sprite selection tile
; 17: empty tile
ld hl, _VRAM_BG_TILES
ld de, BackgroundTiles
ld de, _VRAM_BG_TILES
ld hl, BackgroundTiles
ld bc, BackgroundTilesEnd - BackgroundTiles
call MemoryCopy
call VideoMemoryCopy
ld hl, _VRAM
ld de, SpriteTiles
HaltAndClearInterrupts
call Intro
; copy sprite tiles
HaltAndClearInterrupts
ld de, _VRAM
ld hl, SpriteTiles
ld bc, SpriteTilesEnd - SpriteTiles
call MemoryCopy
call VideoMemoryCopy
; clear OAM
; clear OAM over 4 frames
HaltAndClearInterrupts
ld hl, _OAMRAM
ld d, 0
ld bc, 40 * 4
REPT 2
ld bc, 40 * 2
call MemorySet
HaltAndClearInterrupts
ENDR
; copy default map into 20x18 automata buffer
ld hl, DefaultMap
ld de, Buffer0
ld c, 18
.loopY
ld b, 20
.loopX
ld a, [hl+]
ld [de], a
inc de
dec b
jr nz, .loopX
dec c
jr z, .next
ld a, l
add a, 32 - 20
ld l, a
jr nc, .loopY
inc h
jr .loopY
.next
; set scrolling to (0, 0)
xor a
@@ -138,31 +148,20 @@ Start:
ld a, ANIMATE
ldh [Control], a
; clear screen (both buffers)
ld hl, _SCRN0
ld d, EMPTY_BG_TILE
ld bc, 32 * 32 * 2
call MemorySet
; init buffer 0
ld hl, Buffer0
ld de, DefaultMap
ld bc, 20 * 18
call MemoryCopy
call InitJoypad
call InitAutomata
call InitRender
call InitEdit
; load bg and obj palette [0=black, 1=dark gray, 2=light gray, 3=white]
ld a, %11100100
ldh [rBGP], a
ldh [rOBP0], a
; enable h-blank interrupt in lcd stat
ld a, STATF_MODE00
ld [rSTAT], a
; enable screen but don't display anything yet
ld a, LCDCF_ON
ldh [rLCDC], a
ClearAndEnableInterrupts
.mainloop

View File

@@ -1,88 +0,0 @@
INCLUDE "hardware.inc"
INCLUDE "utils.inc"
EXPORT Random, RandomEnd
SECTION "Random", ROM0, ALIGN[4]
Random:
db -1, 1, 2, -1, 2, 0, -2, -1, -2, 3, -1, -2, 2
RandomEnd:
EXPORT ScrollNintendoOut
SECTION "Scroll Nintendo Out", ROM0
ScrollNintendoOut:
; wait a moment
ld b, 32
.wait
HaltAndClearInterrupts
dec b
jr nz, .wait
; make noise
xor a
ldh [rNR41], a ; set sound duration
ld a, $F0
ldh [rNR42], a ; set volume
ld a, $72
ldh [rNR43], a ; set frequency
ld a, $80
ldh [rNR44], a ; turn on
; nudge nintendo logo
ld d, HIGH(Random)
ld e, 0
ld b, 42
.noise
HaltAndClearInterrupts
HaltAndClearInterrupts
ld a, [de]
ldh [rSCY], a
inc e
ld a, e
cp a, RandomEnd - Random
jr nz, .next
ld e, 0
.next
ld a, [de]
ldh [rSCX], a
inc e
ld a, e
cp a, RandomEnd - Random
jr nz, .next2
ld e, 0
.next2
dec b
jr nz, .noise
xor a
ldh [rSCY], a
; change noise
xor a
ldh [rNR41], a ; set sound duration
ld a, $F4
ldh [rNR42], a ; set volume with long sweep
ld a, $62
ldh [rNR43], a ; set frequency
ld a, $80
ldh [rNR44], a ; start
; nintendo logo lift-off!
.scrollup
HaltAndClearInterrupts
; scroll up
ldh a, [rSCY]
inc a
ldh [rSCY], a
; loop until nintendo logo is out of screen
ldh a, [rSCY]
cp a, 88
jp nz, .scrollup
ret

View File

@@ -2,12 +2,12 @@ INCLUDE "hardware.inc"
EXPORT MemoryCopy
SECTION "Memory Copy", ROM0
; hl = destination
; de = source
; de = destination
; hl = source
; bc = count
MemoryCopy:
ld a, [de]
ld [hl+], a
ld a, [hl+]
ld [de], a
inc de
dec bc
ld a, b
@@ -15,6 +15,24 @@ MemoryCopy:
jr nz, MemoryCopy
ret
EXPORT VideoMemoryCopy
SECTION "Video Memory Copy", ROM0
; de = destination
; hl = source
; bc = count
VideoMemoryCopy:
ldh a, [rSTAT]
and a, STATF_BUSY
jr nz, VideoMemoryCopy
ld a, [hl+]
ld [de], a
inc de
dec bc
ld a, b
or c
jr nz, VideoMemoryCopy
ret
EXPORT MemorySet
SECTION "Memory Set", ROM0
; hl = destination
@@ -28,3 +46,20 @@ MemorySet:
or c
jr nz, MemorySet
ret
EXPORT VideoMemorySet
SECTION "Video Memory Set", ROM0
; hl = destination
; d = data
; bc = count
VideoMemorySet:
ldh a, [rSTAT]
and a, STATF_BUSY
jr nz, VideoMemorySet
ld a, d
ld [hl+], a
dec bc
ld a, b
or c
jr nz, VideoMemorySet
ret

View File

@@ -1,7 +1,9 @@
INCLUDE "hardware.inc"
NINTENDOLOGO_ROM EQU $104
JOYPAD_DIRECTIONS EQU (PADF_UP | PADF_DOWN | PADF_LEFT | PADF_RIGHT)
SWEEP_ENABLE EQU $8
SOUND_EXPIRE EQU $40
SOUND_START EQU $80
PULSE_FREQUENCY EQUS "(-131072 / (FREQUENCY) + 2048)"

View File

@@ -3,8 +3,8 @@
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\automata.o Code\automata.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\render.o Code\render.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\utils.o Code\utils.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\nintendo-out.o Code\nintendo-out.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\intro.o Code\intro.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\edit.o Code\edit.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\joypad.o Code\joypad.asm
..\..\Assembler\rgblink -n rom.sym -w -t -o rom.gb -d Build/main.o Build/data.o Build/automata.o Build/render.o Build/utils.o Build/nintendo-out.o Build/edit.o Build/joypad.o
..\..\Assembler\rgblink -n rom.sym -w -t -o rom.gb -d Build/main.o Build/data.o Build/automata.o Build/render.o Build/utils.o Build/intro.o Build/edit.o Build/joypad.o
..\..\Assembler\rgbfix -t "Game of Life" -v -p 0 rom.gb

BIN
rom.gb

Binary file not shown.

View File

@@ -1,4 +1,3 @@
- music
- title screen
- crossfade nintendo boot logo into nintendo logo in automata
- cartridge!