Browse Source

Begin tile data layout work

master
Forest Belton 2 years ago
parent
commit
78550c91cf
8 changed files with 42 additions and 13 deletions
  1. +24
    -0
      inc/game.inc
  2. +0
    -2
      inc/player.inc
  3. BIN
      png/sprite/item/coin.png
  4. BIN
      png/sprite/item/coin_left.png
  5. BIN
      png/sprite/item/coin_right.png
  6. +8
    -5
      src/item.s
  7. +5
    -5
      src/main.s
  8. +5
    -1
      src/player.s

+ 24
- 0
inc/game.inc View File

@ -1,2 +1,26 @@
; Game states
DEF GAME_STATEF_TITLE EQU (1 << 0)
DEF GAME_STATEF_GAME EQU (1 << 1)
; Player states
DEF PLAYER_STATEF_WALK EQU (1 << 0)
DEF PLAYER_STATEF_JUMP EQU (1 << 1)
; Tile data allocations
DEF ALLOC_SIZE_FONT EQU 37
DEF ALLOC_SIZE_PLAYER EQU 52
DEF ALLOC_SIZE_BACKGROUND EQU 32
DEF ALLOC_SIZE_ITEMS EQU 20
DEF ALLOC_SIZE_MONSTERS EQU 108
DEF TILE_INDEX_FONT EQU 0
DEF TILE_INDEX_PLAYER EQU ALLOC_SIZE_FONT
DEF TILE_INDEX_BACKGROUND EQU ALLOC_SIZE_FONT + ALLOC_SIZE_PLAYER
DEF TILE_INDEX_ITEMS EQU ALLOC_SIZE_FONT + ALLOC_SIZE_PLAYER + ALLOC_SIZE_BACKGROUND
DEF TILE_INDEX_MONSTERS EQU ALLOC_SIZE_FONT + ALLOC_SIZE_PLAYER + ALLOC_SIZE_BACKGROUND + ALLOC_SIZE_ITEMS
ASSERT TILE_INDEX_PLAYER == 37
ASSERT TILE_INDEX_BACKGROUND == 89
ASSERT TILE_INDEX_ITEMS == 121
ASSERT TILE_INDEX_MONSTERS == 141
ASSERT TILE_INDEX_MONSTERS + ALLOC_SIZE_MONSTERS < 256

+ 0
- 2
inc/player.inc View File

@ -1,2 +0,0 @@
DEF PLAYER_STATEF_WALK EQU 0
DEF PLAYER_STATEF_JUMP EQU 1

BIN
png/sprite/item/coin.png View File

Before After
Width: 8  |  Height: 8  |  Size: 228 B

BIN
png/sprite/item/coin_left.png View File

Before After
Width: 8  |  Height: 8  |  Size: 161 B

BIN
png/sprite/item/coin_right.png View File

Before After
Width: 8  |  Height: 8  |  Size: 149 B

+ 8
- 5
src/item.s View File

@ -8,7 +8,6 @@ DEF NEXT_ITEM_ID SET 1
; Declare a new item
; \1 Display name
; \2 Attributes
; \3 Sprite data filename
MACRO Item
ASSERT STRLEN("\1") < 16
@ -25,13 +24,17 @@ MACRO Item
REPT 16 - STRLEN("\1")
DB 0
ENDR
; Sprite data
INCBIN \3
ENDM
SECTION "Item Sprite Data", ROM0
COIN_LEFT:: INCBIN "png/sprite/item/coin_left.2bpp"
COIN_RIGHT:: INCBIN "png/sprite/item/coin_right.2bpp"
SECTION "Item Data", ROM0
; NOTE: Macro invocation MUST be indented in order to be expanded correctly
Items::
Item COIN, ITEM_ATTRF_NONE, "png/sprite/item/coin.2bpp"
Item COIN, ITEM_ATTRF_NONE
SECTION "Item Code", ROM0

+ 5
- 5
src/main.s View File

@ -37,12 +37,12 @@ start:
call OAM_Init
call Keys_Init
; set palette
; set palettes
ld a, %11100100
ld hl, rOBP0
ld [hl], a
ld hl, rBGP
ld [hl], a
ld [rOBP0], a
ld [rBGP], a
ld a, %00011100
ld [rOBP1], a
ld a, GAME_STATEF_TITLE
ld [state], a

+ 5
- 1
src/player.s View File

@ -1,6 +1,6 @@
INCLUDE "game.inc"
INCLUDE "hardware.inc"
INCLUDE "oam.inc"
INCLUDE "player.inc"
INCLUDE "util.inc"
Section "Player Data", WRAM0
@ -369,3 +369,7 @@ Player_AddInvItem::
pop de
ret
; Remove item(s) from the player's inventory
; @param b Item ID
; @param c Item quantity

Loading…
Cancel
Save