Prev: D8DA Up: Map Next: D990
D937: Work out a step's screen position and address
Used by the routines at edge_column and landscape_step_loop.
Screen x = in-cell x (piece_page_x) + horizontal origin (origin_x); screen y = in-cell y (piece_page_y) + vertical origin (origin_y). Both go into the current-piece record (+0, +1) and piece_x/piece_y, and HL is the screen address (pixel_to_screen). For the piece's first step the address is also kept in first_step_address (a character row back when the step hangs off the left edge, x from $F0) and its y in first_step_y; for the piece's first drawn step the screen position is kept in first_step_x/first_step_y_drawn (column_clipped calls the routine's last part for that alone).
Input
IX Current-piece record (current_piece)
Output
HL Screen address of the step
step_screen_address D937 LD A,(piece_page_y) Screen y.
D93A LD H,A
D93B LD A,(origin_y)
D93E ADD A,H
D93F LD H,A
D940 LD (IX+$01),A
D943 LD (piece_y),A
D946 LD A,(piece_page_x) Screen x.
D949 LD L,A
D94A LD A,(origin_x)
D94D ADD A,L
D94E LD L,A
D94F LD (piece_x),A
D952 LD (IX+$00),A
D955 LD D,$00 D = $20 if the step hangs off the left edge; the address.
D957 CP $F0
D959 JR C,step_screen_address_0
D95B LD D,$20
step_screen_address_0 D95D CALL pixel_to_screen
D960 LD A,(piece_steps_done) First step of the piece: keep its address and y.
D963 AND A
D964 JR NZ,step_screen_address_1
D966 LD A,L
D967 SUB D
D968 LD L,A
D969 LD (first_step_address),HL
D96C ADD A,D
D96D LD L,A
D96E LD A,(piece_y)
D971 LD (first_step_y),A
step_screen_address_1 D974 LD A,(clipped_columns) Not the first drawn step: done.
D977 AND A
D978 RET NZ
This entry point is used by the routine at column_clipped.
step_screen_address_2 D979 LD A,(piece_page_x) Keep the first drawn step's screen position (also entered here).
D97C LD B,A
D97D LD A,(origin_x)
D980 ADD A,B
D981 LD (first_step_x),A
D984 LD A,(piece_page_y)
D987 LD B,A
D988 LD A,(origin_y)
D98B ADD A,B
D98C LD (first_step_y_drawn),A
D98F RET
Prev: D8DA Up: Map Next: D990