#define LCDCF_ON 0b10000000
#define LCDCF_OBJON 0b00000010
#define LCDF_WINDOWON 0b00100000
+#define LCDF_OBJ_SIZE 0b00000100
#define RBGP 0xFF47
#define ROBP0 0xFF48
#define P1F4 0b00010000 ; get dpad
; buttons
-#define BTNDOWN 0x80
-#define BTNUP 0x40
-#define BTNLEFT 0x20
-#define BTNRIGHT 0x10
-#define BTNSTART 0x08
-#define BTNSELECT 0x04
-#define BTNA 0x02
-#define BTNB 0x01
+.def int BTNDOWN = 0x80
+.def int BTNUP = 0x40
+.def int BTNLEFT = 0x20
+.def int BTNRIGHT = 0x10
+.def int BTNSTART = 0x08
+.def int BTNSELECT = 0x04
+.def int BTNA = 0x02
+.def int BTNB = 0x01
+
+; obj off-screen offsets
+#define OBJ_OFF_X 8
+#define OBJ_OFF_Y 16
; interrupts
; interrupt flag
+#macro input_just
+
+#endmacro
+
+ ; checks for a button press
+ ; inputs:
+ ; $1 BUTTON
+ ; returns:
+ ; a: button state
+#macro input_held
+ ld a, [curr_inputs]
+ and a, $1
+#endmacro
+
; poll inputs
; returns:
; new inputs in [curr_inputs]
+; player gets 3 sprite slots in a row
+.def int PLAYER_SPRITE1 = shadow_oam + 0
+
+.def int PLAYER_TILE_IDLE1 = 0x04
+.def int PLAYER_TILE_IDLE2 = 0x14
+
; update the player
; players do not behave like regular actors
; and are not allocate to the regular
; inputs:
; hl: pointer to player memory
player_update:
+ ; update
+
+ ; input handling
+ input_held BTNDOWN
+ jr z, @notdown REL
+
+ ld de, player_y
+ add hl, de
+ ld a, [hl]
+ inc a
+ ld [hl], a
+@notdown:
+
+
+ ; drawing
+ ; d: player_y
+ ; e: player_x
+
+ ld a, [hl+]
+ ld d, a
+ ld a, [hl+]
+ ld e, a
+
+ ; obj 1
+ ld hl, PLAYER_SPRITE1
+
+ ; set player position
+ ld a, d ; y
+ add a, OBJ_OFF_Y
+
+ ld [hl+], a
+ ld a, e ; x
+ add a, OBJ_OFF_X
+ ld [hl+], a
+
+ ; idel tile 1
+ ld a, PLAYER_TILE_IDLE1
+ ld [hl+], a
+
+ ; flags
+ xor a, a
+ ld [hl+], a
+
+ ; obj 2
+ ld a, d ; y
+ add a, OBJ_OFF_Y
+ ld [hl+], a
+ ld a, e ; x
+ add a, 8 + OBJ_OFF_X
+ ld [hl+], a
+
+ ; idle tile 2
+ ld a, PLAYER_TILE_IDLE2
+ ld [hl+], a
+
+ ; flags
+ xor a, a
+ ld [hl+], a
+
ret
; turns on the lcd
lcd_on:
- ld a, LCDCF_ON | LCDCF_BGON | LCDCF_OBJON
+ ld a, LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDF_OBJ_SIZE
ld [RLCD], a
ret
; set up bgp
ld a, 0b11100100
ld [RBGP], a
+
+ ld a, 0b11100100
+ ld [ROBP0], a
+
+ ld a, 0b11011000
+ ld [ROBP1], a
+
ret
; copies tilest0 and tileset1 to
.chr 00000000
; tile 4
.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 00033333
+.chr 00322222
+.chr 03222222
+.chr 03222222
+.chr 03221222
+.chr 03221222
+.chr 03221222
; tile 5
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 03221222
+.chr 03221222
+.chr 03222222
+.chr 03222222
+.chr 03222222
+.chr 00322222
+.chr 00033333
.chr 00000000
; tile 6
.chr 00000000
.chr 00000000
; tile 20
.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 33333000
+.chr 22222300
+.chr 22222230
+.chr 22222230
+.chr 21222230
+.chr 21222230
+.chr 21222230
; tile 21
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 21222230
+.chr 21222230
+.chr 22222230
+.chr 22222230
+.chr 22222230
+.chr 22222300
+.chr 33333000
.chr 00000000
; tile 22
.chr 00000000