Skip to content

Commit

Permalink
Merge pull request #150 from PainsPerdus/display
Browse files Browse the repository at this point in the history
Display
  • Loading branch information
DorianXGH committed Jul 2, 2020
2 parents 4b2a58a + fa23aa2 commit 657dc6f
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/check_collisions_isaac_enemies.s
Expand Up @@ -82,7 +82,7 @@ enemies_collide:
xor a
ld (global_.isaac.x), a
ld (global_.isaac.y), a ; //// TODO implement death
ld a, GAMESTATE_TITLESCREEN
ld a, GAMESTATE_GAMEOVER
jp setGameState
@noDeath:
jr @damageDone
Expand Down
78 changes: 78 additions & 0 deletions src/init/gameover_screen.init.s
@@ -0,0 +1,78 @@
gameOverScreenInit:

; ////// Copy Tiles \\\\\\

ld bc,_sizeof_GameOverTiles
ld de,GameOverTiles
ld hl,$8000 ;Block 0 start
@loopTiles: ; while bc != 0
ld a,(de)
ldi (hl),a
inc de
dec bc
ld a,b
or c
jr nz,@loopTiles ; end while
; \\\\\\ Copy Background Tiles //////

; /////// CLEAR BG \\\\\\\
ld de,32*32
ld hl,$9800
@clmap: ; while de != 0
ld a,220;
ldi (hl),a ; *hl <- 220; hl++
dec de ; de --
ld a,e
or d
jr nz,@clmap ; end while
; The Z flag can't be used when dec on 16bit reg :(
; \\\\\\\ CLEAR BG ///////

; /////// COPY BACKGROUND MAP \\\\\\\\

;We need to copy the data (20*18) array, to the first top left bytes of the background map (32*32 array)
ld d,20 ;first loop counter
ld e,_sizeof_GameOverMap/20 ;second loop counter
ld bc,GameOverMap ;data to copy
ld hl,$9800 ;Background Map 1 (to copy to)
@map:
ld a,(bc)
ldi (hl),a ;copy data
inc bc ;setup next byte to copy
dec d
jr nz,@map ;first loop on columns
ld a,e ;save e
ld de, 12
add hl, de ;jump to next bg line
ld e,a ;restore e
ld d,20 ;reset d
dec e
jr nz, @map; second loop on rows

; \\\\\\\ COPY BACKGROUND MAP ////////

; /////// CLEAR OAM \\\\\\\
ld hl,$FE00
ld b,40*4
@clspr: ; while b != 0
ld (hl),$00 ; *hl <- O
inc l ; hl ++ (no ldi hl or inc hl: bug hardware!)
dec b ; b --
jr nz,@clspr ; end while
; set the background offset to 0
xor a
ldh ($42),a
ldh ($43),a
; \\\\\\\ CLEAR OAM ///////

; /////// INIT COLOR PALETTES \\\\\\\
ld a,%11100100 ; 11=Black 10=Dark Grey 01=Grey 00=White/trspt
ldh ($47),a ; background palette
ldh ($48),a ; sprite 0 palette
ldh ($49),a ; sprite 1 palette
; \\\\\\\ INIT COLOR PALETTES ///////

; /////// ENABLE SCREEN \\\\\\\
ld a,%10010001 ; screen on, bg on, tiles at $8000
ldh ($40),a
; \\\\\\\ ENABLE SCREEN ///////
3 changes: 3 additions & 0 deletions src/lib/maps.lib.s
Expand Up @@ -4,3 +4,6 @@ IntroMap1:
IntroMap2:
.INCLUDE "map/introMap2.map"
IntroMapEnd:
GameOverMap:
.INCLUDE "map/gameOver.map"
GameOverMapEnd:
3 changes: 3 additions & 0 deletions src/lib/sprites.lib.s
Expand Up @@ -20,3 +20,6 @@ IntroScreenTiles1:
IntroScreenTiles2:
.INCLUDE "sprites/intro_screen_2.sprite"
IntroScreenEnd:
GameOverTiles:
.INCLUDE "sprites/death_screen_spritesheet.sprite"
GameOverTilesEnd:
30 changes: 27 additions & 3 deletions src/main.s
Expand Up @@ -127,6 +127,8 @@ loop:
jp z, MLstateChangingRoom
cp GAMESTATE_CHANGINGFLOOR
jp z, MLstateChangingFloor
cp GAMESTATE_GAMEOVER
jp z, MLstateGameOver
MLstateTitleScreen:
jp MLend
MLstatePlaying:
Expand All @@ -141,6 +143,8 @@ MLstateChangingFloor:
ld a, GAMESTATE_PLAYING
jp setGameState ;Change gamestate to playing
jp MLend
MLstateGameOver:
jp MLend
MLend:

; \\\\ STATE MACHINE FOR MAIN LOOP ////
Expand Down Expand Up @@ -196,6 +200,8 @@ noSkipFrame:
jp z, VstateChangingRoom
cp GAMESTATE_CHANGINGFLOOR
jp z, VstateChangingFloor
cp GAMESTATE_GAMEOVER
jp z, VstateGameOver
VstateTitleScreen:
.INCLUDE "vblank/title_screen.vbl.s"
jp Vend
Expand All @@ -207,6 +213,8 @@ VstateChangingRoom:
jp Vend
VstateChangingFloor:
jp Vend
VstateGameOver:
jp Vend
Vend:

; //// REALLOW THE LOOP \\\\
Expand Down Expand Up @@ -235,6 +243,8 @@ init:
jp z, IstateChangingRoom
cp GAMESTATE_CHANGINGFLOOR
jp z, IstateChangingFloor
cp GAMESTATE_GAMEOVER
jp z, IstateGameOver
IstateTitleScreen:
; /////// TURN THE SOUND OFF \\\\\\\
xor a ; a=0
Expand Down Expand Up @@ -295,7 +305,20 @@ IstateChangingFloor:
ld a,%10000011 ; screen on, bg on, tiles at $8000
ldh ($40),a
; \\\\\\\ ENABLE SCREEN ///////

jp Iend
IstateGameOver:
; /////// TURN THE SOUND OFF \\\\\\\
xor a ; a=0
ldh ($26),a ; ($FF26) = 0, turn the sound off
; \\\\\\\ TURN THE SOUND OFF ///////
; /////// DISABLE SCREEN \\\\\\\
xor a
ldh ($40), a ; ($FF40) = 0, turn the screen off
; \\\\\\\ DISABLE SCREEN ///////
ld a,%00000001
ldh ($FF),a ; enable VBlank interrupt only
.INCLUDE "init/gameover_screen.init.s"
jp Iend
Iend:
pop de
pop bc
Expand Down Expand Up @@ -333,7 +356,6 @@ waitvlb: ; wait for the line 144 to be refreshed:
.INCLUDE "lib/display_background_tile.lib.s"
.INCLUDE "lib/display_doors.lib.s"
.INCLUDE "lib/display_tears.lib.s"
.INCLUDE "lib/sprites.lib.s"
.INCLUDE "lib/CollisionSolverIsaac.lib.s"
.INCLUDE "lib/collision.lib.s"
.INCLUDE "lib/vectorisation.lib.s"
Expand All @@ -343,7 +365,6 @@ waitvlb: ; wait for the line 144 to be refreshed:
.INCLUDE "lib/knockback.lib.s"
.INCLUDE "lib/load_map.lib.s"
.INCLUDE "lib/door_functions.lib.s"
.INCLUDE "lib/maps.lib.s"
.INCLUDE "lib/display_room.lib.s"
.INCLUDE "lib/stairs_function.lib.s"
.INCLUDE "lib/display_dma.lib.s"
Expand Down Expand Up @@ -372,7 +393,10 @@ room_index:
.ORG $3F00
.DB %11101011, %11101111, %11101011, %11101111, %11100111, %11101111, %11100111, %11101111, %11101101, %11101111, %11101110, %11101111, %11101101, %11101111, %11101110, %11101111, %11011101, %11101111, %11011110, %11101111

;//Load ressources in bank 1
.BANK 1 SLOT 1
.ORGA $4000
.INCLUDE "lib/music.lib.s"
.INCLUDE "lib/maps.lib.s"
.INCLUDE "lib/sprites.lib.s"
.INCLUDE "lib/sfx.lib.s"
21 changes: 21 additions & 0 deletions src/map/gameOver.map
@@ -0,0 +1,21 @@
.DB 218,218,218,218,000,001,002,003,004,005,006,007,008,009,218,218,218,218,218,218
.DB 218,218,218,218,010,011,012,013,014,015,016,017,018,019,020,021,022,023,218,218
.DB 218,218,218,218,024,025,026,027,028,029,030,031,032,033,034,035,036,037,218,218
.DB 218,218,218,038,039,040,041,042,043,219,219,044,045,046,047,048,049,050,218,218
.DB 218,218,218,051,219,219,052,053,054,055,056,219,219,057,058,059,060,061,218,218

.DB 218,218,218,062,063,064,065,066,219,219,067,068,069,219,071,072,073,074,218,218
.DB 218,218,218,075,076,077,078,079,080,081,082,219,083,219,084,085,086,087,218,218
.DB 218,218,088,089,090,091,092,093,094,095,096,097,098,099,100,101,102,218,218,218
.DB 218,218,103,104,105,106,107,108,109,110,111,219,112,113,114,115,116,218,218,218
.DB 218,218,117,118,119,120,121,219,122,123,124,125,126,127,219,219,128,218,218,218
.DB 218,218,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,218,218,218
.DB 218,145,146,147,148,149,150,151,219,152,153,154,219,219,219,219,155,218,218,218
.DB 218,156,157,219,158,159,160,161,162,219,163,219,219,219,219,164,165,218,218,218
.DB 218,166,219,219,219,219,167,168,169,170,171,172,173,174,175,176,218,218,218,218
.DB 218,177,219,219,219,178,179,180,181,182,183,184,185,186,187,188,218,218,218,218
.DB 218,189,190,191,192,193,194,195,196,197,198,199,219,219,219,200,218,218,218,218
.DB 218,218,218,218,201,202,203,204,205,206,207,208,219,219,219,209,218,218,218,218
.DB 218,218,218,218,218,218,218,218,218,218,218,210,211,212,213,214,218,218,218,218


0 comments on commit 657dc6f

Please sign in to comment.