add a, OBJ_OFF_Y
inc de ; de = y_hi
add a, b ; a = y postion
- ld b, a
- ld a, [scroll_y]
- add a, b
ld b, a
ld a, [de] ; a = y_hi
call memcpy
; set a test position
- ld a, 130
+ ld a, 30
ld [actors+act_pos_y], a
ld [actors+act_pos_x], a
; map object types
.se 0
+.de MOT_NOP, 1
.de MOT_SET_PAT, 1
.de MOT_DISABLE_SCROLL, 1
.de MOT_ENABLE_SCROLL, 1
ld a, h
ld [map_scrn_ptr+1], a
+ ; check if we reached the last row of scrn0
+ cp a, 0x97
+ jr nz, @not_end_of_scrn0 REL
+ ; end of scrn0 - wrap around back to first row
+ ld a, SCRN0_END LO
+ ld [map_scrn_ptr], a
+ ld a, SCRN0_END HI
+ ld [map_scrn_ptr+1], a
+@not_end_of_scrn0:
+
; move to next row
ld a, [map_curr_row]
inc a
l1_objs:
modef MOT_SET_PAT, 0, 3, pat_center_grass
modef MOT_SET_PAT, 0, 5, pat_empty
+ modef MOT_NOP, 0, 0xFF, 0
; when an object is off-screen it is unloded
mo_routines:
+ dw mo_nop
dw mo_set_pat
dw mo_disable_scroll
dw mo_enable_scroll
dw mo_rect
dw mo_actor_spawner
+mo_nop:
+ ret
+
; executes all map objects in the map object list
; until the mo's row != current row
; advances mo ptr
; sets up the player actor
player_init:
; initial position
- ld a, 132
+ ld a, 0
ld [player+act_pos_y], a
- ld a, 24
+ ld a, 0
ld [player+act_pos_x], a
ld a, 0
ld [player+act_pos_y_hi], a
- ld a, 0xA0 ; initial next scroll
+ ld a, 0x30 ; initial next scroll
ld [player_next_scroll_y], a
ret
ld a, [RLCD]
or a, LCDCF_OBJON
ld [RLCD], a
+
+ call video_map_perform_scroll
; dma previous frame's oam
call OAMDMAFN
- call video_map_perform_scroll
call scroll_write
ld [scroll_y], a
ld a, [player_next_scroll_y]
- sub a, MAP_ROW_H
+ ; sub a, MAP_ROW_H/2
ld [player_next_scroll_y], a
call map_advance_row
+ call scroll_up_adjust
+
; unset flag
ld a, [game_flags]
and a, ~GPF_SCROLL & 0xFF
ld [game_flags], a
ret
+
+ ; adjusts all actors and rectangles positions
+ ; when a scroll occurs
+scroll_up_adjust:
+ ld b, ACTS_MAX
+ ld hl, actors
+
+@act_loop:
+ push hl
+
+ ld de, act_pos_y
+ add hl, de
+ ld a, [hl]
+ add a, MAP_ROW_H
+ ld [hl+], a ; hl = page y pos hi
+
+ ld a, [hl]
+ adc a, 0
+ ld [hl], a
+
+ pop hl
+
+ dec b
+ ld de, act_size
+ add hl, de
+ jr nz, @act_loop REL
+ ; TODO: adjust rectangles
+ ret
; writes scroll to scroll registers
; only call during blank