GAMEPAD 1
DIM POWER_LOOKUP(16)
CALL SET_POWER_TABLE(POWER_LOOKUP())
PAUSE OFF
SELECTION = 0
DIM WALK_SPEEDS(11)
WALK_SPEEDS(0) = 0.19
WALK_SPEEDS(1) = 0.26
WALK_SPEEDS(2) = 0.30
WALK_SPEEDS(3) = 0.35
WALK_SPEEDS(4) = 0.41
WALK_SPEEDS(5) = 0.48
WALK_SPEEDS(6) = 0.56
WALK_SPEEDS(7) = 0.65
WALK_SPEEDS(8) = 0.76
WALK_SPEEDS(9) = 0.90
WALK_SPEEDS(10) = 1
GRAVITY_STATE = 0
GRAVITY_WAS_FLIPPED = 0
IS_DEBUG = 0
GAME_STATE = 0
MIN_STAGE = 1
MAX_STAGE = 1
GOSUB MAX_MIN_MAP
DIM STAGE_NAMES$(MAX_STAGE - MIN_STAGE + 1)
GOSUB LOAD_STAGE_NAMES
CURRENT_STAGE = MIN_STAGE
AVAILABLE_STAGE = MIN_STAGE
SPR = 33
IS_ON_FLOOR = 0
PLAYER_STATE = 0
PLAYER_X = 64
PLAYER_Y = 64
PLAYER_DX = 0
PLAYER_DY = 0
PLAYER_IS_LEFT = 0
CAN_FLIP_GRAVITY = 1
PLAYER_JUMP_START = PLAYER_DY
JUMP_TIME = 17
FALL_TIME = 10
AIR_TIME = 0
WALK_TIME = 0
PLAYER_JUMP_HEIGHT = 100
VELOCITY = 0
CAN_JUMP = 0
PLAYER_JUMP_GRAVITY = (-2 * PLAYER_JUMP_HEIGHT) / (JUMP_TIME * JUMP_TIME)
PLAYER_JUMP_VELOCITY = (2 * PLAYER_JUMP_HEIGHT) / JUMP_TIME
DOWN_TAPPED = 0
EXIT_X = 0
EXIT_Y = 0
EXIT_GRAVITY = 0
FLOOR_BLOCKS = POWER_LOOKUP(1) OR POWER_LOOKUP(3) OR POWER_LOOKUP(5) OR POWER_LOOKUP(8) OR POWER_LOOKUP(9) OR POWER_LOOKUP(10) OR POWER_LOOKUP(11)
WALL_BLOCKS = POWER_LOOKUP(1) OR POWER_LOOKUP(3) OR POWER_LOOKUP(5) OR POWER_LOOKUP(9) OR POWER_LOOKUP(8)
ROOF_BLOCKS = POWER_LOOKUP(1) OR POWER_LOOKUP(3) OR POWER_LOOKUP(5) OR POWER_LOOKUP(9) OR POWER_LOOKUP(8)
GATE_BLOCKS = POWER_LOOKUP(3) OR POWER_LOOKUP(4) OR POWER_LOOKUP(5) OR POWER_LOOKUP(6)
DIM GRAVITY_BLOCKS(3,3)
SWITCHES_LEFT = 0
IF IS_DEBUG THEN GOSUB STAGE_DEBUG
DIM PASSWORDS(MAX_STAGE + 1)
CALL GENERATE_PASSWORDS(MAX_STAGE,65789,PASSWORDS())
DO
IF GAME_STATE = 0 THEN
CALL TITLE_STATE(GAME_STATE,AVAILABLE_STAGE,MAX_STAGE)
ELSE IF GAME_STATE = 1 THEN
GOSUB MAP_STATE
ELSE IF GAME_STATE = 2 THEN
GOSUB LOAD_STAGE
ELSE IF GAME_STATE = 3 THEN
GOSUB INGAME_STATE
ELSE IF GAME_STATE = 4 THEN
GOSUB PAUSED_STATE
ELSE IF GAME_STATE = 5 THEN
CALL ENTER_PASSWORD(AVAILABLE_STAGE,CURRENT_STAGE,GAME_STATE,PASSWORDS(),MAX_STAGE)
END IF
WAIT VBL
LOOP
SUB TITLE_STATE(GAME_STATE,AVAILABLE_STAGE,MAX_STAGE)
CLS
BG COPY 0,0,20,16 TO 0,0
FONT 64
PAL 4
SELECTION = 0
X = 0
Y = 2
TITLE$ = "GRAVITY GAME"
DIM SELECTIONS$(2)
SELECTIONS$(0) = "START"
SELECTIONS$(1) = "PASSWORD"
CALL CENTER_WORD(X,TITLE$)
TEXT X,Y,TITLE$
TITLE$ = "START"
Y = 9
FOR I = 0 TO 1
CALL CENTER_WORD(X,SELECTIONS$(1))
TEXT X,Y + I * 2,SELECTIONS$(I)
NEXT I
DO
IF PAUSE THEN
CLS
SPRITE OFF 1 TO 2
CALL PLAY_SELECT_SFX
IF SELECTION THEN
GAME_STATE = 5
ELSE
AVAILABLE_STAGE = 1
CALL TO_MAP_SCREEN(GAME_STATE,AVAILABLE_STAGE,MAX_STAGE)
END IF
EXIT SUB
END IF
IF UP TAP(0) OR DOWN TAP(0) THEN
CALL PLAY_SELECT_SFX
SELECTION = ABS(SELECTION - 1)
END IF
SPRITE 1,X * 8,Y * 8 + 16 * SELECTION ,28
SPRITE 2,(X + LEN(SELECTIONS$(SELECTION)) -1) * 8,Y * 8 + 16 * SELECTION,28
SPRITE 2 FLIP 1,0 PAL 6
SPRITE 1 PAL 6
WAIT VBL
LOOP
END SUB
MAP_STATE:
FONT 64
PAL 4
STR_LEN = LEN(STR$(CURRENT_STAGE))
TEXT 2,1," "
NUMBER 9-STR_LEN\2,1, CURRENT_STAGE, STR_LEN
TEXT 2,2," "
STR_LEN = LEN(STAGE_NAMES$(CURRENT_STAGE - 1))
TEXT 9 - STR_LEN\2,2, STAGE_NAMES$(CURRENT_STAGE - 1)
PAL 1
IF AVAILABLE_STAGE > 1 THEN TEXT 9 - 2,3,STR$(PASSWORDS(AVAILABLE_STAGE))
IF PAUSE THEN
GAME_STATE = 2
SPRITE OFF 19
CALL PLAY_SELECT_SFX
WALK_TIME = 0
DO
IF WALK_TIME = 30 THEN
CLS
RETURN
END IF
INC WALK_TIME
WAIT VBL
LOOP
ELSE IF RIGHT TAP(0) THEN
INC CURRENT_STAGE
CURRENT_STAGE = MIN( AVAILABLE_STAGE,MIN(MAX_STAGE,CURRENT_STAGE))
ELSE IF LEFT TAP(0) THEN
DEC CURRENT_STAGE
CURRENT_STAGE = MAX(MIN_STAGE,CURRENT_STAGE)
ELSE IF DOWN TAP(0) THEN
IF (CURRENT_STAGE + 18) <= MAX_STAGE AND (CURRENT_STAGE + 18) <= AVAILABLE_STAGE THEN ADD CURRENT_STAGE,18
ELSE IF UP TAP(0) THEN
IF (CURRENT_STAGE - 18) > 0 THEN ADD CURRENT_STAGE,-18
END IF
IF RIGHT TAP(0) OR LEFT TAP(0) OR UP TAP(0) OR DOWN TAP(0) THEN CALL PLAY_SELECT_SFX
CALL DRAW_CURSOR(CURRENT_STAGE)
RETURN
SUB DRAW_CURSOR(STAGE)
X = 0
Y = 0
IF STAGE MOD 18 = 0 THEN
X = 18
ELSE
X = STAGE MOD 18
Y = STAGE \ 18
END IF
X = X * 8
Y = 40 + Y * 16
SPRITE 19, X,Y,27
SPRITE 19 PAL 6
END SUB
SUB TO_MAP_SCREEN(GAME_STATE,AVAILABLE_STAGE,MAX_STAGE)
CLS
X = 0
Y = 5
GAME_STATE = 1
CURRENT_STAGE = 1
FOR I = 1 TO MAX_STAGE \ 18
FOR J = 1 TO 18
INC X
CALL DRAW_STAGE_TILE(X,Y,CURRENT_STAGE,AVAILABLE_STAGE)
INC CURRENT_STAGE
NEXT J
X = 0
ADD Y,2
NEXT I
FOR I = 1 TO MAX_STAGE MOD 18
INC X
CALL DRAW_STAGE_TILE(X,Y,CURRENT_STAGE,AVAILABLE_STAGE)
INC CURRENT_STAGE
NEXT I
END SUB
SUB DRAW_STAGE_TILE(X,Y,CURRENT_STAGE,AVAILABLE_STAGE)
IF CURRENT_STAGE = AVAILABLE_STAGE THEN
CELL X,Y,24
TINT X,Y PAL 5
ELSE IF CURRENT_STAGE < AVAILABLE_STAGE THEN
CELL X,Y,26
TINT X,Y PAL 4
ELSE
CELL X,Y,25
TINT X,Y PAL 5
END IF
END SUB
INGAME_STATE:
IF PAUSE THEN
CALL TO_PAUSE_STATE(GAME_STATE,SELECTION)
RETURN
END IF
GRAVITY_WAS_FLIPPED = 0
GOSUB PROCESS_PLAYER
GOSUB PROCESS_ACTIVE_CELLS
RETURN
PAUSED_STATE:
IF PAUSE THEN
SPRITE OFF 19 TO 22
IF SELECTION = 0 THEN
GAME_STATE = 3
ELSE IF SELECTION = 1 THEN
GAME_STATE = 2
ELSE
CALL TO_MAP_SCREEN(GAME_STATE,AVAILABLE_STAGE,MAX_STAGE)
END IF
RETURN
END IF
IF (LEFT TAP(0) AND SELECTION > 0) OR (RIGHT TAP(0) AND SELECTION < 2) THEN CALL PLAY_SELECT_SFX
SELECTION = SELECTION + LEFT TAP(0) - RIGHT TAP(0)
SELECTION = MIN(MAX(0,SELECTION),2 )
SPRITE 19,68 + SELECTION * 8,60,27
SPRITE 19 PAL 6
RETURN
SUB TO_PAUSE_STATE(GAME_STATE,SELECTION)
X = 68
Y = 60
SELECTION = 0
GAME_STATE = 4
FOR I = 0 TO 2
ADD X,8 * ABS(I >0)
SPRITE 20 + I, X,Y,29 + I
SPRITE 20 + I PAL 7
SPRITE OFF 1
NEXT I
END SUB
PROCESS_PLAYER:
GOSUB CHECK_ON_FLOOR
IF IS_ON_FLOOR THEN CAN_FLIP_GRAVITY = 1
IF PLAYER_STATE < 5 AND BUTTON TAP(0,0) AND CAN_FLIP_GRAVITY THEN
GOSUB FLIP_GRAVITY
END IF
IF PLAYER_STATE = 0 THEN
GOSUB PROCESS_PLAYER_IDLE
GOSUB CHECK_ON_WALL
ELSE IF PLAYER_STATE = 1 THEN
GOSUB PROCESS_PLAYER_WALK
GOSUB CHECK_ON_WALL
ELSE IF PLAYER_STATE = 2 THEN
GOSUB PROCESS_PLAYER_JUMP
GOSUB CHECK_ON_WALL
ELSE IF PLAYER_STATE = 3 THEN
GOSUB PROCESS_PLAYER_FLIP
ELSE IF PLAYER_STATE = 4 THEN
GOSUB PROCESS_PLAYER_FALL
IF PLAYER_DX THEN GOSUB CHECK_ON_WALL
ELSE IF PLAYER_STATE = 5 THEN
GOSUB PROCESS_PLAYER_DEATH
ELSE IF PLAYER_STATE = 6 THEN
GOSUB PROCESS_STAGE_END
END IF
IF GAME_STATE = 3 THEN GOSUB DRAW_PLAYER
RETURN
DRAW_PLAYER:
IF GRAVITY_STATE = 0 THEN
ADD PLAYER_X,PLAYER_DX
ADD PLAYER_Y,PLAYER_DY
ELSE IF GRAVITY_STATE = 1 THEN
ADD PLAYER_X,PLAYER_DX
ADD PLAYER_Y,-PLAYER_DY
ELSE IF GRAVITY_STATE = 2 THEN
ADD PLAYER_X,-PLAYER_DY
ADD PLAYER_Y,PLAYER_DX
ELSE IF GRAVITY_STATE = 3 THEN
ADD PLAYER_X,PLAYER_DY
ADD PLAYER_Y,PLAYER_DX
END IF
FLIP_Y = GRAVITY_STATE = 1 OR ( GRAVITY_STATE > 1 AND PLAYER_IS_LEFT )
FLIP_X = GRAVITY_STATE = 3 OR ( GRAVITY_STATE < 2 AND PLAYER_IS_LEFT )
PLAYER_PALETTE = 2
IF AIR_TIME > 65 THEN
PLAYER_PALETTE = 1
ELSE IF CAN_FLIP_GRAVITY THEN
PLAYER_PALETTE = 0
END IF
SPRITE 1,PLAYER_X,PLAYER_Y, SPR
SPRITE 1 PAL PLAYER_PALETTE FLIP FLIP_X,FLIP_Y
RETURN
PROCESS_PLAYER_DEATH:
FOR I = 0 TO 2
GRAVITY_BLOCKS(I,0) = -1
GRAVITY_BLOCKS(I,1) = -1
NEXT I
INC WALK_TIME
CAN_FLIP_GRAVITY = 0
PLAYER_DX = 0
PLAYER_DY = 0
IF BUTTON TAP(0,0) AND WALK_TIME > 25 THEN
CLS
GAME_STATE = 2
END IF
SPR = 40
IF WALK_TIME > 20 THEN SPR = 41
IF GRAVITY_STATE > 1 THEN ADD SPR,16
RETURN
PROCESS_STAGE_END:
INC WALK_TIME
FOR I = 0 TO 2
GRAVITY_BLOCKS(I,0) = -1
GRAVITY_BLOCKS(I,1) = -1
NEXT I
IF WALK_TIME > 60 THEN
PLAYER_STATE = 0
SPRITE OFF 0 TO 63
IF CURRENT_STAGE = AVAILABLE_STAGE THEN
AVAILABLE_STAGE = MIN(MAX_STAGE,AVAILABLE_STAGE + 1)
END IF
INC CURRENT_STAGE
CURRENT_STAGE = MIN(MAX_STAGE,CURRENT_STAGE)
CALL TO_MAP_SCREEN(GAME_STATE,AVAILABLE_STAGE,MAX_STAGE)
RETURN
END IF
RETURN
END_STAGE:
CALL PLAY_CONFIRM_SFX
PLAYER_STATE = 6
WALK_TIME = 0
RETURN
PROCESS_PLAYER_IDLE:
PLAYER_DX = 0
PLAYER_DY = 0
CAN_JUMP = 7
IF GRAVITY_STATE = EXIT_GRAVITY THEN
GOSUB CHECK_DOWN_TAPPED
IF GRAVITY_STATE < 2 THEN
IF EXIT_Y = PLAYER_Y AND ABS(EXIT_X - PLAYER_X) < 4 AND DOWN_TAPPED AND SWITCHES_LEFT = 0 THEN
GOSUB END_STAGE
RETURN
END IF
ELSE
IF EXIT_X = PLAYER_X AND ABS(EXIT_Y - PLAYER_Y) < 4 AND DOWN_TAPPED AND SWITCHES_LEFT = 0 THEN
GOSUB END_STAGE
RETURN
END IF
END IF
END IF
IF IS_ON_FLOOR = 0 THEN
AIR_TIME = 17
PLAYER_STATE = 4
RETURN
END IF
IF ( GRAVITY_STATE < 2 AND ( LEFT(0) OR RIGHT ( 0 ) ) ) OR ( GRAVITY_STATE > 1 AND ( UP(0) OR DOWN ( 0 ) ) ) THEN
PLAYER_STATE = 1
RETURN
ELSE IF BUTTON TAP(0,1) THEN
CAN_JUMP = 0
VELOCITY = PLAYER_JUMP_VELOCITY
PLAYER_STATE = 2
END IF
SPR = 33
IF GRAVITY_STATE < 2 THEN SPR = 33 ELSE SPR = 49
WALK_TIME = 0
RETURN
PROCESS_PLAYER_FLIP:
ADD AIR_TIME,1
GOSUB CHECK_ROOF
IF AIR_TIME = 10 THEN
AIR_TIME = 17
PLAYER_STATE = 4
RETURN
END IF
SPR = 38 + (TIMER / 30 MOD 2)
IF GRAVITY_STATE > 1 THEN ADD SPR,14
RETURN
PROCESS_PLAYER_JUMP:
ADD AIR_TIME,1
PLAYER_DY = ((-PLAYER_JUMP_HEIGHT/((8-0) * (8-17)) ) *(AIR_TIME - 0) * (AIR_TIME - 17))/60
GOSUB CHECK_ROOF
IF ROOF_CHECK_1 > 15 THEN ROOF_CHECK_1 = 0
IF ROOF_CHECK_2 > 15 THEN ROOF_CHECK_2 = 0
IF (POWER_LOOKUP(ROOF_CHECK_1) AND ROOF_BLOCKS) OR (POWER_LOOKUP(ROOF_CHECK_2) AND ROOF_BLOCKS) THEN PLAYER_DY = 0.5
IF PLAYER_DY > 0 THEN
PLAYER_STATE = 4
AIR_TIME = 17
RETURN
END IF
SPR = 36
IF GRAVITY_STATE > 1 THEN ADD SPR,16
RETURN
PROCESS_PLAYER_WALK:
ADD WALK_TIME,1
WALK_TIME = MIN(WALK_TIME,10)
IF IS_ON_FLOOR = 0 THEN
AIR_TIME = 17
PLAYER_STATE = 4
RETURN
END IF
IF (LEFT(0) AND GRAVITY_STATE < 2) OR (UP(0) AND GRAVITY_STATE > 1) THEN
PLAYER_DX = -WALK_SPEEDS(WALK_TIME)
PLAYER_IS_LEFT = 1
ELSE IF (RIGHT(0) AND GRAVITY_STATE < 2) OR (DOWN(0) AND GRAVITY_STATE > 1) THEN
PLAYER_DX = WALK_SPEEDS(WALK_TIME)
PLAYER_IS_LEFT = 0
ELSE
WALK_TIME = 0
PLAYER_STATE = 0
END IF
IF BUTTON TAP(0,1) THEN
VELOCITY = PLAYER_JUMP_VELOCITY
PLAYER_STATE = 2
RETURN
END IF
SPR = 34 + (TIMER/8 MOD 2)
IF GRAVITY_STATE > 1 THEN ADD SPR,16
RETURN
SUB CHECK_FALL_IN_LAVA(FC1,FC2,PS)
IF FC1 = 2 OR FC2 = 2 THEN PS = 5
END SUB
SUB CHECK_IF_ON_GROUND(FC1,FC2,IS_ON_FLOOR,PL(),FB)
IF FC1 < 16 THEN
IF PL(FC1) AND FB THEN
IS_ON_FLOOR = 1
END IF
ELSE IF FC2 < 16 THEN
IF PL(FC2) AND FB THEN
IS_ON_FLOOR = 1
END IF
END IF
END SUB
SUB PLACE_ON_FLOOR(PLAYER_PIXEL_AXIS,DY,LOC_Y,GRAVITY_STATE,CHECK_GS_1,CHECK_GS_2)
IF GRAVITY_STATE = CHECK_GS_1 THEN
PLAYER_PIXEL_AXIS = 8 * ((LOC_Y\8) ) - 8
DY = 0
ELSE IF GRAVITY_STATE = CHECK_GS_2 THEN
PLAYER_PIXEL_AXIS = 8 * ((LOC_Y\8) ) + 8
DY = 0
END IF
END SUB
SUB CHECK_HIGH_FALL(AIR_TIME,WALK_TIME,PLAYER_STATE)
IF AIR_TIME > 65 THEN
WALK_TIME = 0
PLAYER_STATE = 5
END IF
END SUB
PROCESS_PLAYER_FALL:
ADD AIR_TIME,1
DEC CAN_JUMP
IF PLAYER_X < -30 OR PLAYER_Y < -30 OR PLAYER_X > 190 OR PLAYER_Y > 160 THEN
CALL PLAY_DEATH_SFX
PLAYER_STATE = 5
RETURN
END IF
IF CAN_JUMP > 0 AND BUTTON TAP(0,1) THEN
AIR_TIME = 0
CAN_JUMP = 0
VELOCITY = PLAYER_JUMP_VELOCITY
PLAYER_STATE = 2
RETURN
END IF
IF AIR_TIME < 30 AND CAN_FLIP_GRAVITY THEN
IF GRAVITY_STATE < 2 THEN
IF LEFT(0) THEN ADD PLAYER_DX , -0.1 ELSE IF RIGHT(0) THEN ADD PLAYER_DX,0.1
ELSE
IF UP(0) THEN ADD PLAYER_DX , -0.1 ELSE IF DOWN(0) THEN ADD PLAYER_DX,0.1
END IF
IF PLAYER_IS_LEFT THEN
PLAYER_DX = MIN(0,MAX(-1,PLAYER_DX))
ELSE
PLAYER_DX = MIN(1,MAX(0,PLAYER_DX))
END IF
END IF
IS_ON_FLOOR = 0
IF GRAVITY_STATE < 2 THEN
LOC_X1 = PLAYER_X + 3
LOC_X2 = PLAYER_X + 4
LOC_Y1 = PLAYER_Y + PLAYER_DY
IF GRAVITY_STATE = 0 THEN ADD LOC_Y1,7 ELSE ADD LOC_Y1,-5
FLOOR_CHECK_1 = CELL.C( LOC_X1 \ 8,LOC_Y1 \ 8)
FLOOR_CHECK_2 = CELL.C( LOC_X2 \ 8,LOC_Y1 \ 8)
CALL CHECK_FALL_IN_LAVA(FLOOR_CHECK_1,FLOOR_CHECK_2,PLAYER_STATE)
IF PLAYER_STATE = 5 THEN
ADD PLAYER_Y,PLAYER_DY
CALL PLAY_DEATH_SFX
IF GRAVITY_STATE = 1 THEN ADD PLAYER_Y,-7
RETURN
END IF
IF FLOOR_CHECK_1 > 15 THEN FLOOR_CHECK_1 = 0
IF FLOOR_CHECK_2 > 15 THEN FLOOR_CHECK_2 = 0
CALL CHECK_IF_ON_GROUND(FLOOR_CHECK_1,FLOOR_CHECK_2,IS_ON_FLOOR,POWER_LOOKUP(),FLOOR_BLOCKS)
IF IS_ON_FLOOR THEN
CALL PLACE_ON_FLOOR(PLAYER_Y,PLAYER_DY,LOC_Y1,GRAVITY_STATE,0,1)
CALL CHECK_HIGH_FALL(AIR_TIME,WALK_TIME,PLAYER_STATE)
IF PLAYER_STATE = 5 THEN
PLAY 0,42,7 SOUND 3
RETURN
END IF
PLAYER_STATE = 0
AIR_TIME = 0
RETURN
END IF
ELSE
LOC_X1 = PLAYER_Y + 3
LOC_X2 = PLAYER_Y + 4
LOC_Y1 = PLAYER_X + PLAYER_DY
IF GRAVITY_STATE = 3 THEN ADD LOC_Y1,7 ELSE ADD LOC_Y1,-7
FLOOR_CHECK_1 = CELL.C( LOC_Y1 \ 8,LOC_X1 \ 8)
FLOOR_CHECK_2 = CELL.C( LOC_Y1 \ 8,LOC_X2 \ 8)
CALL CHECK_FALL_IN_LAVA(FLOOR_CHECK_1,FLOOR_CHECK_2,PLAYER_STATE)
IF PLAYER_STATE = 5 THEN
ADD PLAYER_X,PLAYER_DY
CALL PLAY_DEATH_SFX
IF GRAVITY_STATE = 2 THEN ADD PLAYER_X,-7
RETURN
END IF
IF FLOOR_CHECK_1 > 15 THEN FLOOR_CHECK_1 = 0
IF FLOOR_CHECK_2 > 15 THEN FLOOR_CHECK_2 = 0
CALL CHECK_IF_ON_GROUND(FLOOR_CHECK_1,FLOOR_CHECK_2,IS_ON_FLOOR,POWER_LOOKUP(),FLOOR_BLOCKS)
IF IS_ON_FLOOR THEN
CALL PLACE_ON_FLOOR(PLAYER_X,PLAYER_DY,LOC_Y1,GRAVITY_STATE,3,2)
CALL CHECK_HIGH_FALL(AIR_TIME,WALK_TIME,PLAYER_STATE)
IF PLAYER_STATE = 5 THEN
PLAY 0,42,7 SOUND 3
RETURN
END IF
PLAYER_STATE = 0
AIR_TIME = 0
RETURN
END IF
END IF
ADD AIR_TIME,1
PLAYER_DY = ((-PLAYER_JUMP_HEIGHT/((15-10) * (15-20)) ) *(AIR_TIME - 10) * (AIR_TIME - 20))/120
PLAYER_DY = SGN(PLAYER_DY) * MIN(2,ABS(PLAYER_DY))
SPR = 37
IF GRAVITY_STATE > 1 THEN ADD SPR,14
RETURN
FLIP_GRAVITY:
IF GRAVITY_STATE < 2 THEN
IF GRAVITY_STATE = 0 AND UP(0) THEN
GRAVITY_STATE = 1
ELSE IF GRAVITY_STATE = 1 AND DOWN(0) THEN
GRAVITY_STATE = 0
ADD PLAYER_Y,1
ELSE IF PLAYER_IS_LEFT THEN
IF GRAVITY_STATE = 1 THEN PLAYER_IS_LEFT = 0
GRAVITY_STATE = 2
ELSE
IF GRAVITY_STATE = 0 THEN PLAYER_IS_LEFT = 1
GRAVITY_STATE = 3
END IF
ELSE
IF GRAVITY_STATE = 2 AND RIGHT(0) THEN
GRAVITY_STATE = 3
ELSE IF GRAVITY_STATE = 3 AND LEFT(0) THEN
GRAVITY_STATE = 2
ELSE IF PLAYER_IS_LEFT THEN
IF GRAVITY_STATE = 2 THEN PLAYER_IS_LEFT = 0
GRAVITY_STATE = 1
ELSE
IF GRAVITY_STATE = 3 THEN PLAYER_IS_LEFT = 1
GRAVITY_STATE = 0
END IF
END IF
PLAY 1,73,15 SOUND 12
GOSUB CHECK_ON_FLOOR
WHILE IS_ON_FLOOR
IF GRAVITY_STATE = 0 THEN
DEC PLAYER_Y
ELSE IF GRAVITY_STATE = 1 THEN
INC PLAYER_Y
ELSE IF GRAVITY_STATE = 2 THEN
INC PLAYER_X
ELSE
DEC PLAYER_X
END IF
GOSUB CHECK_ON_FLOOR
WEND
PLAYER_DX = 0
PLAYER_DY = 0
PLAYER_STATE = 3
AIR_TIME = 0
CAN_FLIP_GRAVITY = 0
GRAVITY_WAS_FLIPPED = 1
RETURN
CHECK_ROOF:
IF GRAVITY_STATE = 0 THEN
LOC_Y = PLAYER_Y + PLAYER_DY
LOC_X1 = PLAYER_X + 3
LOC_X2 = PLAYER_X + 4
ELSE IF GRAVITY_STATE = 1 THEN
LOC_Y = PLAYER_Y - PLAYER_DY + 6
LOC_X1 = PLAYER_X + 3
LOC_X2 = PLAYER_X + 4
ELSE IF GRAVITY_STATE = 2 THEN
LOC_Y = PLAYER_X - PLAYER_DY + 6
LOC_X1 = PLAYER_Y + 3
LOC_X2 = PLAYER_Y + 4
ELSE IF GRAVITY_STATE = 3 THEN
LOC_Y = PLAYER_X + PLAYER_DY
LOC_X1 = PLAYER_Y + 3
LOC_X2 = PLAYER_Y + 4
END IF
IF GRAVITY_STATE < 2 THEN
ROOF_CHECK_1 = CELL.C( LOC_X1\8 , LOC_Y\8)
ROOF_CHECK_2 = CELL.C( LOC_X2\8 , LOC_Y\8)
ELSE
ROOF_CHECK_1 = CELL.C( LOC_Y \ 8,LOC_X1 \ 8)
ROOF_CHECK_2 = CELL.C( LOC_Y \ 8,LOC_X2 \ 8)
END IF
RETURN
CHECK_ON_WALL:
FLOORGRAV = ABS(GRAVITY_STATE < 2)
WALLGRAV = ABS(GRAVITY_STATE > 1)
LOC_X1 = (PLAYER_X\1 * FLOORGRAV) + (PLAYER_Y\1 * WALLGRAV) + 2
LOC_X2 = LOC_X1 +3
LOC_Y1 = (PLAYER_Y * FLOORGRAV) + (PLAYER_X * WALLGRAV)
LOC_Y2 = LOC_Y1 + 7
IF GRAVITY_STATE < 2 THEN
IF CAN_FLIP_GRAVITY = 0 AND GRAVITY_STATE = 0 THEN ADD LOC_Y1, 3 ELSE IF CAN_FLIP_GRAVITY THEN ADD LOC_Y2, - 3
WALL_CHECK_1 = CELL.C( LOC_X1 \ 8,LOC_Y1 \ 8)
WALL_CHECK_2 = CELL.C( LOC_X1 \ 8,LOC_Y2 \ 8)
WALL_CHECK_3 = CELL.C( LOC_X2 \ 8,LOC_Y1 \ 8)
WALL_CHECK_4 = CELL.C( LOC_X2 \ 8,LOC_Y2 \ 8)
IF PLAYER_IS_LEFT THEN
CALL PROCESS_WALL(WALL_CHECK_1,PLAYER_DX,PLAYER_X,LOC_X1,5,POWER_LOOKUP(),WALL_BLOCKS)
CALL PROCESS_WALL(WALL_CHECK_2,PLAYER_DX,PLAYER_X,LOC_X1,5,POWER_LOOKUP(),WALL_BLOCKS)
ELSE
CALL PROCESS_WALL(WALL_CHECK_3,PLAYER_DX,PLAYER_X,LOC_X2,-5,POWER_LOOKUP(),WALL_BLOCKS)
CALL PROCESS_WALL(WALL_CHECK_4,PLAYER_DX,PLAYER_X,LOC_X2,-5,POWER_LOOKUP(),WALL_BLOCKS)
END IF
ELSE
IF CAN_FLIP_GRAVITY = 0 AND GRAVITY_STATE = 3 THEN ADD LOC_Y1, 3 ELSE IF CAN_FLIP_GRAVITY THEN ADD LOC_Y2, - 3
WALL_CHECK_1 = CELL.C( LOC_Y1 \ 8,LOC_X1 \ 8)
WALL_CHECK_2 = CELL.C( LOC_Y2 \ 8,LOC_X1 \ 8)
WALL_CHECK_3 = CELL.C( LOC_Y1 \ 8,LOC_X2 \ 8)
WALL_CHECK_4 = CELL.C( LOC_Y2 \ 8,LOC_X2 \ 8)
IF PLAYER_IS_LEFT THEN
CALL PROCESS_WALL(WALL_CHECK_1,PLAYER_DX,PLAYER_Y,LOC_X1,5,POWER_LOOKUP(),WALL_BLOCKS)
CALL PROCESS_WALL(WALL_CHECK_2,PLAYER_DX,PLAYER_Y,LOC_X1,5,POWER_LOOKUP(),WALL_BLOCKS)
ELSE
CALL PROCESS_WALL(WALL_CHECK_3,PLAYER_DX,PLAYER_Y,LOC_X2,-5,POWER_LOOKUP(),WALL_BLOCKS)
CALL PROCESS_WALL(WALL_CHECK_4,PLAYER_DX,PLAYER_Y,LOC_X2,-5,POWER_LOOKUP(),WALL_BLOCKS)
END IF
END IF
GOSUB CHECK_LAVA_COLLISION
RETURN
SUB PROCESS_WALL(WC,DX,X,LOCX,OFFSET,PL(),WB)
IF WC > 0 AND WC < 16 THEN
IF PL(WC) AND WB THEN
DX = 0
X = 8 * (LOCX \ 8) + OFFSET
END IF
END IF
END SUB
CHECK_LAVA_COLLISION:
IF WALL_CHECK_1 = 2 OR WALL_CHECK_2 = 2 OR WALL_CHECK_3 = 2 OR WALL_CHECK_4 = 2 THEN
PLAYER_STATE = 5
CALL PLAY_DEATH_SFX
RETURN
END IF
RETURN
CHECK_ON_FLOOR:
IF GRAVITY_STATE = 0 THEN
LOC_Y = (PLAYER_Y + 9)\8
LOC_X1 = (PLAYER_X + 3)\8
LOC_X2 = (PLAYER_X + 4)\8
ELSE IF GRAVITY_STATE = 1 THEN
LOC_Y = (PLAYER_Y - 2)\8
LOC_X1 = (PLAYER_X + 3)\8
LOC_X2 = (PLAYER_X + 4)\8
ELSE IF GRAVITY_STATE = 2 THEN
LOC_Y = (PLAYER_X - 2)\8
LOC_X1 = (PLAYER_Y + 3)\8
LOC_X2 = (PLAYER_Y + 4)\8
ELSE
LOC_Y = (PLAYER_X + 9)\8
LOC_X1 = (PLAYER_Y + 3)\8
LOC_X2 = (PLAYER_Y + 4)\8
END IF
IF GRAVITY_STATE < 2 THEN
FLOOR_CHECK_1 = CELL.C( LOC_X1,LOC_Y)
FLOOR_CHECK_2 = CELL.C( LOC_X2,LOC_Y)
ELSE
FLOOR_CHECK_1 = CELL.C( LOC_Y,LOC_X1)
FLOOR_CHECK_2 = CELL.C( LOC_Y,LOC_X2)
END IF
IS_ON_FLOOR = 0
IF FLOOR_CHECK_1 <> 0 OR FLOOR_CHECK_2 <> 0 THEN
IF FLOOR_CHECK_1 < 16 THEN
IF POWER_LOOKUP(FLOOR_CHECK_1) AND FLOOR_BLOCKS THEN IS_ON_FLOOR = 1
ELSE IF FLOOR_CHECK_2 < 16 THEN
IF POWER_LOOKUP(FLOOR_CHECK_2) AND FLOOR_BLOCKS THEN IS_ON_FLOOR = 1
END IF
IF IS_ON_FLOOR AND SWITCHES_LEFT > 0 THEN
IF GRAVITY_STATE < 2 THEN
CALL CHECK_FOR_SWITCH( LOC_X1,LOC_Y,SWITCHES_LEFT)
CALL CHECK_FOR_SWITCH( LOC_X2,LOC_Y,SWITCHES_LEFT)
ELSE
CALL CHECK_FOR_SWITCH( LOC_Y,LOC_X1,SWITCHES_LEFT)
CALL CHECK_FOR_SWITCH( LOC_Y,LOC_X2,SWITCHES_LEFT)
END IF
IF SWITCHES_LEFT = 0 THEN
CELL EXIT_X\8,EXIT_Y\8,17 + ABS(EXIT_GRAVITY > 1)
TINT EXIT_X\8,EXIT_Y\8 FLIP EXIT_GRAVITY = 3 , EXIT_GRAVITY = 1
END IF
END IF
END IF
RETURN
SUB CHECK_FOR_SWITCH(CX,CY,SL)
PITCH = 49
IF CELL.C(CX,CY) = 8 THEN
PLAY 0,(PITCH - SL) + 5 *ABS(SL = 1),15 + 45 * ABS(SL = 1) SOUND 1
DEC SL
CELL CX,CY,9
TINT CX,CY PAL 0
END IF
END SUB
PROCESS_ACTIVE_CELLS:
IF GRAVITY_WAS_FLIPPED THEN
CALL PROCESS_GATE_CELLS(GRAVITY_STATE,GATE_BLOCKS)
END IF
GOSUB PROCESS_GRAV_CELLS
RETURN
SUB PROCESS_GATE_CELLS(GSTATE,GBS)
C = 0
ATT = 0
FOR X = 0 TO 19
FOR Y = 0 TO 15
C = CELL.C(X,Y)
ATT = CELL.A(X,Y)
FLIP_X = 8 AND ATT
FLIP_Y = 16 AND ATT
IF C = 4 THEN
IF GSTATE = 3 AND FLIP_X THEN
CELL X,Y,3
ELSE IF GSTATE = 2 AND FLIP_X = 0 THEN
CELL X,Y,3
END IF
ELSE IF C = 3 THEN
IF GSTATE = 2 AND FLIP_X THEN
CELL X,Y,4
ELSE IF GSTATE = 3 AND FLIP_X = 0 THEN
CELL X,Y,4
END IF
ELSE IF C = 6 THEN
IF GSTATE = 1 AND FLIP_Y = 0 THEN
CELL X,Y,5
ELSE IF GSTATE = 0 AND FLIP_Y THEN
CELL X,Y,5
END IF
ELSE IF C = 5 THEN
IF GSTATE = 1 AND FLIP_Y THEN
CELL X,Y,6
ELSE IF GSTATE = 0 AND FLIP_Y = 0 THEN
CELL X,Y,6
END IF
END IF
TINT X,Y FLIP FLIP_X > 0,FLIP_Y > 0
NEXT Y
NEXT X
END SUB
PROCESS_GRAV_CELLS:
I = 0
CLEARCELLS = POWER_LOOKUP(0) OR POWER_LOOKUP(4) OR POWER_LOOKUP(6)
WHILE GRAVITY_BLOCKS(I,2) <> 0 AND I < 3
X_INC = 0
Y_INC = 0
IF GRAVITY_BLOCKS(I,0) = -4 THEN
IF GRAVITY_STATE = 3 THEN X_INC = 1
ELSE IF GRAVITY_BLOCKS(I,0) = 23 THEN
IF GRAVITY_STATE = 2 THEN X_INC = -1
ELSE IF GRAVITY_BLOCKS(I,1) = -4 THEN
IF GRAVITY_STATE = 0 THEN Y_INC = 1
ELSE IF GRAVITY_BLOCKS(I,1) = 18 THEN
IF GRAVITY_STATE = 1 THEN Y_INC = -1
ELSE IF GRAVITY_STATE = 0 THEN
Y_INC = 1
ELSE IF GRAVITY_STATE = 1 THEN
Y_INC = -1
ELSE IF GRAVITY_STATE = 2 THEN
X_INC = -1
ELSE
X_INC = 1
END IF
TARGET_CELL = CELL.C(GRAVITY_BLOCKS(I,0) + X_INC,GRAVITY_BLOCKS(I,1)+ Y_INC)
IF TARGET_CELL > 15 THEN TARGET_CELL = 1
WHILE (POWER_LOOKUP(TARGET_CELL) AND CLEARCELLS) AND (GRAVITY_BLOCKS(I,0) + X_INC <> -4) AND (GRAVITY_BLOCKS(I,0) + X_INC <> 23) AND (GRAVITY_BLOCKS(I,1) + Y_INC <> -4) AND (GRAVITY_BLOCKS(I,1) + Y_INC <> 18)
IF GRAVITY_STATE = 0 THEN
INC Y_INC
ELSE IF GRAVITY_STATE = 1 THEN
DEC Y_INC
ELSE IF GRAVITY_STATE = 2 THEN
DEC X_INC
ELSE
INC X_INC
END IF
TARGET_CELL = CELL.C(GRAVITY_BLOCKS(I,0) + X_INC,GRAVITY_BLOCKS(I,1)+ Y_INC)
IF TARGET_CELL > 15 THEN TARGET_CELL = 1
WEND
'CHECK IF NOT OUT OF BOUNDS
IF (GRAVITY_BLOCKS(I,0) + X_INC <> -4) AND (GRAVITY_BLOCKS(I,0) + X_INC <> 23) AND (GRAVITY_BLOCKS(I,1) + Y_INC <> -4) AND (GRAVITY_BLOCKS(I,1) + Y_INC <> 23) THEN
IF GRAVITY_STATE = 0 THEN
DEC Y_INC
ELSE IF GRAVITY_STATE = 1 THEN
INC Y_INC
ELSE IF GRAVITY_STATE = 2 THEN
INC X_INC
ELSE
DEC X_INC
END IF
END IF
FLIP_X = 0
FLIP_Y = 0
CELL_VAL = 10
IF GRAVITY_STATE > 1 THEN CELL_VAL = 11
IF GRAVITY_STATE = 1 THEN
FLIP_Y = 1
ELSE IF GRAVITY_STATE = 2 THEN
FLIP_X = 1
END IF
IF (TIMER / 30 MOD 2) THEN P = 4 ELSE P = 5
CELL GRAVITY_BLOCKS(I,0),GRAVITY_BLOCKS(I,1),0
ADD GRAVITY_BLOCKS(I,0),X_INC
ADD GRAVITY_BLOCKS(I,1),Y_INC
CELL GRAVITY_BLOCKS(I,0),GRAVITY_BLOCKS(I,1),CELL_VAL
TINT GRAVITY_BLOCKS(I,0),GRAVITY_BLOCKS(I,1) FLIP FLIP_X,FLIP_Y PAL P
INC I
WEND
FLIP 0,0
RETURN
LOAD_STAGE:
CLS
BG 1
PAL 3
RESTORE STAGES
READ KEY$,VALUE
SWITCHES_LEFT = 0
FOR I = 0 TO 2
GRAVITY_BLOCKS(I,2) = 0
NEXT I
WHILE (KEY$ <> "S" OR VALUE <> CURRENT_STAGE)
IF KEY$ = "STAGEEND" THEN RETURN
READ KEY$,VALUE
WEND
WHILE KEY$ <> "END" AND KEY$<>"STAGEEND"
READ KEY$,VALUE
IF KEY$ = "P" THEN
GOSUB SET_PLAYER
ELSE IF KEY$ = "GS" THEN
GOSUB SET_GRAVITY
ELSE IF KEY$ = "GB" THEN
CALL SET_GROUND_BLOCK(VALUE)
ELSE IF KEY$ = "GL" THEN
CALL SET_GROUND_LINE(VALUE)
ELSE IF KEY$ = "LB" THEN
CALL SET_LAVA_BLOCK(VALUE)
ELSE IF KEY$ = "LL" THEN
CALL SET_LAVA_LINE(VALUE)
ELSE IF KEY$ = "GATEB" THEN
CALL SET_GATE_BLOCK(VALUE)
ELSE IF KEY$ = "GATEL" THEN
CALL SET_GATE_LINE(VALUE)
ELSE IF KEY$ = "SB" THEN
CALL SET_SWITCH(VALUE,SWITCHES_LEFT)
ELSE IF KEY$ = "GRAVB" THEN
CALL SET_GRAVITY_BLOCK(VALUE,GRAVITY_BLOCKS())
ELSE IF KEY$ = "SL" THEN
CALL SET_SWITCHES(VALUE,SWITCHES_LEFT)
ELSE IF KEY$ = "EX" THEN
CALL SET_EXIT(VALUE,EXIT_X,EXIT_Y,GRAVITY_STATE,EXIT_GRAVITY)
END IF
WEND
PLAYER_STATE = 0
AIR_TIME = 0
WALK_TIME = 0
GAME_STATE = 3
RETURN
SET_PLAYER:
PLAYER_X = (VALUE \ 100) * 8
PLAYER_Y = (VALUE MOD 100) * 8
RETURN
SET_GRAVITY:
GRAVITY_STATE = VALUE
RETURN
SUB SET_SWITCH(D,SL)
' D = XXYY
INC SL
CALL SET_CELL_2(D,8,2)
END SUB
SUB SET_SWITCHES(D,SL)
'D = XXYYLL
X_INC = ABS(D > 0)
Y_INC = ABS(D < 0)
D = ABS(D)
X = D \ 10000
Y = (D \ 100) MOD 100
FOR I = 1 TO D MOD 100
CALL SET_SWITCH(D \ 100,SL)
ADD D,X_INC * 10000
ADD D,Y_INC * 100
NEXT I
END SUB
SUB SET_CELL(X,Y,CELL_VAL,FLIPX,FLIPY,P)
CELL X,Y,CELL_VAL
TINT X,Y PAL P FLIP FLIPX,FLIPY
END SUB
SUB SET_CELL_LINE(X,Y,CELL_VAL,FLIPX,FLIPY,P,COUNT,IS_COLUMN)
FOR I = 1 TO COUNT
IF IS_COLUMN THEN INC Y ELSE INC X
CALL SET_CELL(X,Y,CELL_VAL,FLIPX,FLIPY,P)
NEXT I
END SUB
SUB SET_GRAVITY_BLOCK(D,GRAVITY_BLOCK_ARRAY())
'D = XXYYLL
CALL SET_CELL_2(D,10,3)
FOR I = 0 TO 2
IF GRAVITY_BLOCK_ARRAY(I,2) = 0 THEN
GRAVITY_BLOCK_ARRAY(I,0) = D \ 100
GRAVITY_BLOCK_ARRAY(I,1) = D MOD 100
GRAVITY_BLOCK_ARRAY(I,2) = 1
EXIT SUB
END IF
NEXT I
END SUB
SUB SET_GROUND_BLOCK(D)
'D = XXYY
CALL SET_CELL_2(D,1,3)
END SUB
SUB SET_GROUND_LINE(D)
'D = +/- XXYYLL
IS_COLUMN = ABS(D < 0)
GROUND_LENGTH = ABS( D MOD 100 )
X = ABS(D \ 10000)
Y = ABS((D \100 ) MOD 100)
FOR I = 1 TO GROUND_LENGTH
CALL SET_GROUND_BLOCK(X * 100 + Y)
ADD X,ABS(IS_COLUMN = 0)
ADD Y,IS_COLUMN
NEXT I
END SUB
SUB SET_CELL_2(D,V,P)
'D = XXYY
X = D \ 100
Y = D MOD 100
CELL X,Y,V
TINT X,Y PAL P
END SUB
SUB SET_CELL_F(D,V,P,FX,FY)
X = D \ 100
Y = D MOD 100
CELL X,Y,V
TINT X,Y PAL P FLIP FX,FY
END SUB
SUB SET_LAVA_BLOCK(D)
'D = XXYY
CALL SET_CELL_2(D,2,3)
END SUB
SUB SET_LAVA_LINE(D)
IS_COLUMN = ABS(D < 0)
GROUND_LENGTH = ABS( D MOD 100 )
X = ABS(D \ 10000)
Y = ABS((D \100 ) MOD 100)
FOR I = 1 TO GROUND_LENGTH
CALL SET_LAVA_BLOCK(X * 100 + Y)
ADD X,ABS(IS_COLUMN = 0)
ADD Y,IS_COLUMN
NEXT I
END SUB
SUB SET_GATE_BLOCK(D)
'D = XXYY dir active
GRAV = (D MOD 100)\10
CELL_VAL = 3
ACTIVE = D MOD 10
IF GRAV < 2 THEN CELL_VAL = 5
IF ACTIVE = 0 THEN INC CELL_VAL
CALL SET_CELL_F(D \ 100,CELL_VAL,3,GRAV = 3,GRAV = 0 )
END SUB
SUB SET_GATE_LINE(D)
'D = XXYY dir active LL
IS_COLUMN = ABS(D < 0)
GROUND_LENGTH = ABS( D MOD 100 )
D = ABS (D \ 100)
FOR I = 1 TO GROUND_LENGTH
CALL SET_GATE_BLOCK(D)
ADD D, 10000 * ABS(IS_COLUMN = 0)
ADD D, 100 * IS_COLUMN
NEXT I
END SUB
SUB SET_EXIT(D,EX,EY,GS,EG)
'D = XX YY EG(0-3) LOCKED(0,1)
LOCKED = D MOD 10
EXIT_GRAVITY = (D \ 10) MOD 10
Y = (D \ 100) MOD 100
X = D \ 10000
CALL SET_CELL_F( D \ 100 , (17 + ABS(EXIT_GRAVITY > 1) + LOCKED * 2) , 3,EXIT_GRAVITY = 3 , EXIT_GRAVITY = 1)
EX = X * 8
EY = Y * 8
EG = EXIT_GRAVITY
END SUB
MAX_MIN_MAP:
RESTORE STAGES
REPEAT
READ KEY$,VALUE
IF KEY$ = "S" THEN
IF VALUE < MIN_STAGE THEN
MIN_STAGE = VALUE
ELSE IF VALUE > MAX_STAGE THEN
MAX_STAGE = VALUE
END IF
END IF
UNTIL KEY$ = "STAGEEND"
RETURN
CHECK_DOWN_TAPPED:
IF GRAVITY_STATE = 0 AND DOWN TAP(0) THEN
DOWN_TAPPED = 1
RETURN
END IF
IF GRAVITY_STATE = 1 AND UP TAP(0) THEN
DOWN_TAPPED = 1
RETURN
END IF
IF GRAVITY_STATE = 2 AND LEFT TAP(0) THEN
DOWN_TAPPED = 1
RETURN
END IF
IF GRAVITY_STATE = 3 AND RIGHT TAP(0) THEN
DOWN_TAPPED = 1
RETURN
END IF
DOWN_TAPPED = 0
RETURN
LOAD_STAGE_NAMES:
RESTORE STAGES
INDEX = 0
REPEAT
READ KEY$,VALUE
IF VALUE = -12345 THEN
STAGE_NAMES$(INDEX) = KEY$
ELSE IF KEY$ = "S" THEN
INDEX = VALUE - 1
END IF
UNTIL KEY$ = "STAGEEND"
RETURN
SUB GENERATE_PASSWORDS(AVAILABLE_STAGE,SEED,PASSWORDS())
RANDOMIZE SEED
FOR I = 0 TO AVAILABLE_STAGE + 1
PLACED = 0
PWD = 0
CALL GENERATE_PASSWORD(PWD)
X = 0
WHILE PLACED = 0
IF X = I THEN
PLACED = 1
PASSWORDS(I) = PWD
ELSE IF PASSWORDS(X) <> PWD THEN
INC X
ELSE IF PASSWORDS(X) = PWD THEN
CALL GENERATE_PASSWORD(PWD)
X = 0
END IF
WEND
NEXT I
END SUB
SUB GENERATE_PASSWORD(PWD)
PWD = 1000 + RND(8999)
END SUB
SUB FIND_PASSWORD(PASSWORDS(),PASSWORD,UPTO,RESULT)
RESULT = 0
FOR I = 0 TO UPTO
IF PASSWORDS(I) = PASSWORD THEN
RESULT = I
EXIT SUB
END IF
NEXT I
END SUB
SUB ENTER_PASSWORD(AVAILABLE_STAGE,CURRENT_STAGE,GAME_STATE,PASSWORDS(),MAX_STAGE)
SELECTION = 0
DIM PASSWORD(4)
TITLE$ = "ENTER PASSWORD"
X = 0
Y = 4
CALL CENTER_WORD(X,TITLE$)
TEXT X,Y,TITLE$
DO
IF LEFT TAP(0) OR RIGHT TAP(0) OR UP TAP(0) OR DOWN TAP(0) THEN CALL PLAY_SELECT_SFX
IF LEFT TAP(0) THEN
DEC SELECTION
IF SELECTION = -1 THEN SELECTION = 3
ELSE IF RIGHT TAP(0) THEN
INC SELECTION
IF SELECTION = 4 THEN SELECTION = 0
END IF
IF UP TAP(0) THEN
INC PASSWORD(SELECTION)
IF PASSWORD(SELECTION) = 10 THEN PASSWORD(SELECTION) = 0
ELSE IF DOWN TAP(0) THEN
DEC PASSWORD(SELECTION)
IF PASSWORD(SELECTION) = -1 THEN PASSWORD(SELECTION) = 9
END IF
IF PAUSE THEN
PWD = PASSWORD(0)*1000 + PASSWORD(1)*100 + PASSWORD(2)*10 + PASSWORD(3)
CALL FIND_PASSWORD(PASSWORDS(),PWD,MAX_STAGE,AVAILABLE_STAGE)
IF AVAILABLE_STAGE > 1 THEN
CURRENT_STAGE = AVAILABLE_STAGE
CALL TO_MAP_SCREEN(GAME_STATE,AVAILABLE_STAGE,MAX_STAGE)
WALK_TIME = 0
CALL PLAY_CONFIRM_SFX
DO
INC WALK_TIME
SPRITE OFF 1
IF WALK_TIME = 30 THEN
EXIT SUB
END IF
LOOP
END IF
END IF
CALL CENTER_WORD(X,"1234")
Y = 7
SPRITE 1 ,((X * 8) + SELECTION * 8),Y * 8,27
SPRITE 1 PAL 6
FOR I = 0 TO 3
NUMBER X + I, 7 , PASSWORD(I) ,1
NEXT I
WAIT VBL
LOOP
END SUB
SUB CENTER_WORD(X,W$)
X = 9 - LEN(W$)\2
END SUB
SUB SET_POWER_TABLE(T())
RESTORE POWERS
INDEX = 0
REPEAT
READ KEY,VALUE
T(INDEX) = KEY
INC INDEX
IF VALUE <> -1 THEN T(INDEX) = VALUE
INC INDEX
UNTIL INDEX > 15
END SUB
SUB PLAY_DEATH_SFX
PLAY 0,49,30 SOUND 13
END SUB
SUB PLAY_SELECT_SFX
PLAY 0,85 SOUND 4
END SUB
SUB PLAY_CONFIRM_SFX
PLAY 0, 82 SOUND 2
END SUB
STAGE_DEBUG:
GAME_STATE = 2
AVAILABLE_STAGE = MAX_STAGE
CURRENT_STAGE = AVAILABLE_STAGE
RETURN
STAGES:
'TRAINING
DATA "S",1,"JUMP",-12345,"P",0406,"GS",0,"GL",030706,"GL",110706,"EX",150600,"END",1
DATA "S",2,"WALL WALK",-12345,"P",0609,"GS",0,"GL",051008,"GL",-120209,"EX",110330,"END",2
DATA "S",3,"CEILING CRAWL",-12345,"P",0409,"GS",0,"GL",031006,"GL",080508,"EX",150610,"END",3
DATA "S",4,"FLIP FLOP",-12345,"P",0309,"GS",0,"GL",031004,"GL",-061102,"GL",070507,"GL",141003,"EX",071220,"END",4
DATA "S",5,"FATAL FALL",-12345,"P",0502,"GS",0,"GL",050303,"GL",-070407,"GL",071504,"GL",-120304,"GL",130302,"EX",101400,"END",5
'REGULAR
DATA "S",6,"CHRIS CROSS",-12345,"P",0701,"GS",0,"GL",040405,"GL",-060205,"GL",120405,"GL",-140205,"GL",081305,"GL",-101105,"EX",091430,"END",6
DATA "S",7,"TETRAS",-12345,"P",0306,"GS",0,"GL",020802,"GL",030702,"GL",-090604,"GL",081403,"GB",1015,"GL",-140703,"GB",1509
DATA "GL",-161202,"GL",-151302,"GL",140302,"GL",140402,"GL",-100303,"GB",1104,"EX",140200,"END",7
DATA "S",8,"RIGHT THERE",-12345,"P",0501,"GS",0,"GL",050203,"GL",-050208,"GL",091004,"GL",-130209,"GL",021005,"GL",-021103,"GL",150302,"GL",-121302,"EX",130100,"END",8
DATA "S",9,"LINE LEAPS",-12345,"P",0307,"GS",3,"GL",-010204,"GL",010804,"GL",-040503,"GL",-110202,"GL",051304,"GL",-121104,"GL",-181302,"GL",140202,"GL",170203,"EX",130230,"END",9
DATA "S",10, "BLOCKS",-12345,"P",0104,"GS",0,"GL",040102,"GL",040202,"GL",000602,"GL",000502,"GL",080602,"GL",080502,"GL",140602,"GL",140502
DATA "GL",041002,"GL",040902,"GL",101002,"GL",100902,"GL",181002,"GL",180902,"GL",141402,"GL",141302,"EX",160520,"END",10
'LAVA
DATA "S",11, "SOUTH POLE",-12345,"P",1002,"GS",0,"GL",090303,"GL",091303,"GL",070407,"GL",071207,"GL",060509,"GL",061109,"GL",050611,"GL",050711,"GL",050811,"GL",050911,"GL",051011
DATA "LL",090403,"LL",080505,"LL",070607,"LL",060710,"LL",050811,"LL",050910,"LL",071007,"LL",081105,"LL",091203,"EX",101410,"END",11
DATA "S",12,"SAFE ZONES",-12345,"P",0305,"GS",0,"GL",020615,"GL",-020703,"LL",030911,"GL",-160604,"GL",090903,"GL",140902,"GL",-150103
DATA "GL",-151203,"GL",041102,"GL",-041102,"GL",030902,"LL",030713,"LL",030813,"LL",060603,"LB",0705,"LL",120502,"LL",120602,"LB",1304
DATA "LL",121002,"LB",1311,"LL",-121102,"GB",1014,"EX",010630,"END",12
DATA "S",13,"YOYO",-12345,"P",1101,"GS",0,"GL",100202,"GL",100302,"GL",070502,"LL",070602,"GL",040802,"LL",040902,"GL",011102,"GL",011203,"LL",070903
DATA "GL",071002,"GB",0811,"LL",-091002,"GL",071502,"GL",-111302,"LL",-121302,"GL",171002,"GL",171102,"GL",-140702,"LL",-130604
DATA "LL",110902,"GL",111002,"LB",1406,"EX",120220,"END",13
DATA "S",14,"PATHFINDER",-12345,"P",0504,"GS",1,"GB",0503,"LL",060202,"LB",0301,"LB",0306,"LL",-120202,"LL",-120502,"LL",-120802
DATA "LB",0409,"LL",060902,"LL",090902,"LL",031102,"LL",061102,"LL",001402,"GL",170003,"GL",170103,"GL",-190202
DATA "GL",130202,"GL",-130202,"GL",-170502,"GL",-160802,"GL",160802,"GL",-171203,"GL",-181203,"GL",061403,"GL",031506
DATA "GB",0400,"GB",0900,"GB",1006,"GB",0400,"GB",0102,"GL",-000602,"GL",-011002,"GB",0508,"GB",0910,"GB",1113,"EX",100020,"END",14
DATA "S",15,"DANGER FLIPS",-12345,"P",0214,"GS",0,"GL",011503,"LL",-010707,"LL",-030905,"GL",020707,"GL",-040904,"GL",-080802,"LL",071003,"LL",071203
DATA "GL",-110904,"LL",-130402,"LL",-150402,"GL",100206,"GL",-010303,"LL",060605,"LL",110502,"LL",030303,"LL",030503,"EX",020420,"END",15
'SWITCHES
DATA "S",16,"SWITCH IT UP",-12345,"P",0708,"GS",2,"EX",060821,"GL",-050703,"GL",-150703,"SL",080505,"SL",081105,"END",16
DATA "S",17,"PARKOUR",-12345,"P",1007,"GS",0,"GL",090804,"LL",060404,"LL",060803,"SL",-140702,"SL",-170402,"SL",-191002,"SL",171502,"SL",141002,"SL",121502,"SL",091002,"SL",061502,"SL",031002,"SL",-001003
DATA "SL",-000402,"SL",-040602,"SL",020202,"SL",050003,"SL",080302,"SL",-120103,"EX",050621,"END",17
DATA "S",18,"HANA",-12345,"P",1009,"GS",3,"SL",070105,"SL",071305,"SL",-030505,"SL",-150505,"SL",040402,"SL",130402,"SL",041002,"SL",131002,"SL",-060202,"SL",-120202,"SL",-061102,"SL",-121102
DATA "LL",-090603,"LL",080703,"GB",0604,"GB",0705,"GB",1204,"GB",1006,"GB",1008,"GB",1109,"GB",0610,"GB",0709,"GB",0808,"GL",-111402,"GL",-121303,"GB",1314,"GB",1413,"GL",151203,"GL",151304,"GL",151403,"EX",040511,"END",18
DATA "S",19,"PATHFINDER 2",-12345,"P",0504,"GS",1,"GB",0503,"LL",060202,"LB",0301,"LB",0306,"LL",-120202,"LL",-120502,"LL",-120802
DATA "LB",0409,"LL",060902,"LL",090902,"LL",031102,"LL",061102,"LL",001402,"GL",180002,"GB",1901, "SL",-170002,"SL",-190202,"SB",1801
DATA "SL",130202,"SB",1303,"SL",-170502,"SL",-160802,"SB",1708,"SL",-171203,"SL",-181203,"SL",061403,"SL",031503,"GL",061503
DATA "SB",0400,"SB",0900,"SB",1006,"SB",0102,"SL",-000602,"SL",-011002,"SB",0508,"SB",0910,"SB",1113,"EX",100021,"END",19
DATA "S",20,"FOUR STEP",-12345,"P",1006,"GS",0,"GL",090702,"GL",090802,"GL",010004,"GB",0401,"GL",060402,"GB",0703,"LL",000508,"SB",0101
DATA "GL",120003,"GL",-130405,"GL",-190103,"SB",1801,"LB",1407,"LL",-150704,"LL",-160703,"GL",170703,"LB",1809,"LL",001520,"LB",1111,"LL",111303,"GB",1112,"GL",101502,"GB",1614,"GB",1715,"GB",1915,"SB",1815
DATA "LL",001410,"LL",021308,"LL",061203,"GB",0512,"GB",0011,"GB",0107,"GB",0406,"GB",0609,"GB",0610,"GB",0007,"SB",0114,"EX",090601,"END",20
'GRAVITY BLOCK
DATA "S",21,"GRAVITY BLOCK",-12345,"P",1410,"GS",0,"GL",111206,"GL",030314,"GL",-160310,"GL",-030310,"GL",-110705,"GL",-070405,"LL",031208,"LB",0309,"LB",0311,"GRAVB",1411,"EX",040510,"END",21
DATA "S",22,"MONITOR TWO",-12345,"P",0503,"GS",0,"GL",-040103,"GB",0502,"GL",110203,"GB",1203,"GL",-150003,"GB",1601,"GL",-190303,"GL",-010603,"GB",0007,"GL",030703,"GB",0406
DATA "GL",080803,"GB",0907,"GL",120803,"GB",1307,"GL",031203,"GB",0411,"GL",091103,"GB",1012,"GL",-170903,"GB",1810,"GL",01503,"GB",0114,"GL",051503,"GB",0614,"GL",-131303,"GB",1414,"GL",161503,"GB",1714,"GRAVB",0301,"EX",130410,"END",22
DATA "S",23,"LAVA SEA",-12345,"P",0402,"GS",0,"GRAVB",0204,"LB",1604,"LL",-180404,"LL",-170404,"LL",130306,"LL",130206,"LL",130106,"LL",090402,"LL",060905,"LL",081203,"GB",1709,"GB",1107
DATA "GL",-121103,"GL",071304,"GL",-001104,"GL",021102,"GL",021202,"GL",-120102,"GL",030502,"GL",030602,"LL",000020,"LL",001520,"LL",-000114,"LL",-190114,"LL",010503,"LL",010603,"GB",1007,"GL",-001104,"EX",170830,"END",23
DATA "S",24,"DOORS?",-12345,"P",1005,"GS",0,"GB",1006,"GB",0806,"GB",1115,"GB",0615,"GB",0106,"LB",0900,"LB",1601,"LB",1914,"LB",0014,"LL",001502,"LL",181502,"SL",-090702,"SB",1000,"SB",1408,"SB",1213,"SB",1015,"SB",0515,"SB",211
DATA "GRAVB",0906,"EX",031121,"EX",151511,"EX",181231,"EX",140701,"EX",110621,"EX",080501,"EX",0105001,"EX",080131,"EX",080831,"END",24
DATA "S",25,"TWO STEPS",-12345,"P",0704,"GS",0,"GB",1607,"GB",0107,"GB",1008,"GB",0509,"GB",0111,"GB",0814
DATA "LL",000020,"LL",-000114,"LL",001520,"LL",-190114,"GL",050504,"GL",-050302,"GL",050005,"GL",-090102,"LB",1504,"LB",1403,"LB",1805,"GRAVB",0513,"GRAVB",1606,"EX",170630,"END",25
'GATE
DATA "S",26,"BRIDGE",-12345,"P",0201,"GS",1,"GATEL",01042103,"GATEL",-04051103,"GATEL",07062009,"GATEL",07072109,"GATEL",-11081008
DATA "GL",-160404,"GL",-170404,"GL",-180107,"GL",-190107,"GL",160004,"GL",010003,"GL",-000107,"GL",000805,"GL",-040104,"EX",121020,"END",26
DATA "S",27,"GATE",-12345,"P",0403,"GS",0,"GL",-030114,"GL",-160114,"GATEL",-08023102,"GATEL",-11022102,"GATEL",-08051102,"GATEL",-11050102,"GB",0801,"GB",0804,"GB",0807,"GB",1101,"GB",1104,"GB",1107
DATA "GATEL",04010104,"GATEL",04040104,"GATEL",04071104,"GATEL",12011104,"GATEL",12041104,"GATEL",12071104,"SB",0301,"SB",0306,"SB",1604,"SB",1107,"SB",0314,"SB",1612,"EX",070631,"END",27
DATA "S",28,"BLOCKED",-12345,"P",0206,"GS",0,"GATEL",04120002,"GATEL",09120002,"GATEL",-15063002,"GATEL",-15023002,"GL",-060502,"GL",-151002,"GL",-100802,"SL",-160202,"SL",-160602,"SL",041302,"SL",091302
DATA "GL",-151302,"GL",-151002,"GL",131202,"GL",161202,"GL",010102,"GL",060102,"GL",110102,"GATEL",-01071203,"GATEL",-02071203,"LL",061203,"LL",-150402,"LL",011002,"EX",030721,"END",28
DATA "S",29,"ORBIT",-12345,"P",0508,"GS",0,"GL",040903,"GL",041003,"GL",041103,"GATEL",14023003,"GATEL",14033003,"GATEB",160410,"GATEL",14043002,"GATEL",-04050002,"GATEL",-06141002,"GATEL",00113002,"GATEL",09092102
DATA "GATEL",-12040102,"GATEL",-14062004,"GATEL",-19121002,"GATEL",-19020005,"LB",1305,"GATEL",07091002,"EX",181230,"END",29
DATA "S",30,"CONTROL",-12345,"P",0501,"GS",0,"GATEL",-07031002,"GATEL",-07060002,"GATEL",05052102,"GATEL",08053102 ,"GATEL",-12031102,"GATEL",-12060102,"GATEL",10052002,"GATEL",13053002,"GB",0705,"GB",1205
DATA "LL",001018,"LL",000020,"LL",-000020,"LL",-190020,"LL",001520,"LL",170102,"LB",1802,"GRAVB",0114,"GL",-051302,"GL",-141302,"LB",1011,"LB",0911,"LB",1112,"LB",0812,"GB",0814,"GB",1114
DATA "GATEB",021231,"GATEB",041221,"GATEB",031111,"GATEB",031301, "GATEB",061221,"GATEB",071111,"GATEB",071301,"GATEB",121101,"GATEB",121311,"GATEB",131231,"GATEB",151211,"GATEB",161131,"GATEB",161321,"GATEB",171201,"EX",170330,"END",30
DATA "STAGEEND",112358
POWERS:
DATA 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,-1
#1:MAIN PALETTES
1B3E000C003E0030003E002A002A0030
1B001D2A0000352A00301500003F2A00
#2:MAIN CHARACTERS
00000000000000000000000000000000
007E5E7E7E7C7800FF81A181818387FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
007E7E7E7E7E7E00FF8191E1E19181FF
00000010601000000000001060100000
007E7E7E7E7E7E00FF9999A5818181FF
00101028000000000010102800000000
55800180018001AAFFFFFFFFFFFFFFFF
187E7EFFFF7E7E18E7818118188181E7
003C7E7E7E7E3C00FFC381999981C3FF
0018180000000000FFE7241800000000
0000006060000000C0C0E09090E0C0C0
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
003C665A5A673C182418BD7E7EBC183C
3C4242424642427E003C3C3C3C3C3C00
00FE81818191FE0000007E7E7E7E0000
3C62564A5662427E001C2834281C3C00
00FEA3958995FE0000005C6A766A0000
7EE7C39898C3E76700183C7F7F3D1B1F
DBDBDB0000DBDBDB000000FFFF000000
00000000000000000000000000000000
FFFFFFFFFFFFFFFF007E7E7E7E7E7E00
FFBDDBE7E7DBBDFF007E7E7E7E7E7E00
FFFDF9F3A78FDFFF007E7E7E7E7E7E00
C3810000000081C30000000000000000
E0808000008080E00000000000000000
FFFFFFFFFFFFFFFFFFFFEFE7E3E7EFFF
FFFFFFFFFFFFFFFFFFFBD0BAAE85EFFF
FFFFFFFFFFFFFFFFFFFFC1C1C1C1C1FF
00000000000000000000000000000000
00180038240018183820383818181818
000C0038003008081C101C1818380808
000C0038200018281C101C3818181828
00180038202C18103820383838181810
0018007A001018083820383C18181808
0099041C8100181838A1381899181818
0018859D000018183820B99918181818
0000000C001C203600001C101C1C1C3C
00000000000050B40000000000067FCB
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
000018CACA10000000000FFDFD000000
00002828CA0200000000203FFD050000
00009848CA0200000000887FFD050000
000038CA6A20000000001FFD7D000000
0008086ACA00080000000F7DFD080000
120000CACA0C0012120007FDFD000012
0C0000CACA0C000C0C0007FDFD00000C
0000C0A028A88000000080FCF4F40000
804080C00080000080C04040C060E0C0
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00181818180018000000000000000000
006C6C24000000000000000000000000
00247E24247E24000000000000000000
00083E380E3E08000000000000000000
00626408102646000000000000000000
001C34386E643A000000000000000000
00181830000000000000000000000000
000C183030180C000000000000000000
0030180C0C1830000000000000000000
000024187E1824000000000000000000
000018187E1818000000000000000000
00000000181830000000000000000000
000000007E0000000000000000000000
00000000001818000000000000000000
00060C18306040000000000000000000
003C666E76663C000000000000000000
0018381818187E000000000000000000
003C660C18307E000000000000000000
003C660C06663C000000000000000000
0066667E060606000000000000000000
007E607C06067C000000000000000000
001C307C66663C000000000000000000
007E060C183030000000000000000000
003C663C66663C000000000000000000
003C663E06663C000000000000000000
00000018001800000000000000000000
00000018001830000000000000000000
00000C1830180C000000000000000000
0000007E007E00000000000000000000
000030180C1830000000000000000000
003C660C180018000000000000000000
003C666E6E603C000000000000000000
00183C667E6666000000000000000000
007C667C66667C000000000000000000
003C666060663C000000000000000000
00786C66666C78000000000000000000
007E607860607E000000000000000000
007E6078606060000000000000000000
003C606E66663C000000000000000000
0066667E666666000000000000000000
003C181818183C000000000000000000
001E060606663C000000000000000000
00666C78786C66000000000000000000
0060606060607E000000000000000000
0042667E7E6666000000000000000000
0066767E6E6666000000000000000000
003C666666663C000000000000000000
007C667C606060000000000000000000
003C66666A6C3E000000000000000000
007C667C786C66000000000000000000
003E603C06067C000000000000000000
007E1818181818000000000000000000
0066666666663C000000000000000000
00666666663C18000000000000000000
0066667E7E6642000000000000000000
00663C183C6666000000000000000000
0066663C181818000000000000000000
007E0C1830607E000000000000000000
003C303030303C000000000000000000
006030180C0602000000000000000000
003C0C0C0C0C3C000000000000000000
00183C66000000000000000000000000
0000000000007E000000000000000000
#3:MAIN BG
00001410000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000090000000000000000
00000000000000000000000000000000
000000000000000B0009000000000009
00090000000000000000000000000000
00000000000000000000000000000009
00090000000000090000000000000000
00000000000000000000000000000000
00000000000000000009000000000009
00000000000000000000000000000000
00000000000000000000000000000000
00090000000000000000000000000000
00000000000000000000000000000000
00000000000900000000000000000000
00000000000000000000000000000000
00000000000000000000000000090000
00000000000000000000000000100000
00000000000000000000000000000000
00000000000900000000000000000000
00000000001000000000000000000000
00000000000000000000280900000000
00000000000000000000000000100000
00000000000000000000000000000000
31080900321000000000000000000000
00000000000000000000000000000000
00000000000000000000211000000000
00000000000000000000000000020002
00020002000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000
#15:MAIN SOUND
0800303A000000001800846C003A0000
5819006902AA00002800303019FE0000
38002020000000003800505000000000
0800000F000000000800000F00000000
0800000F00000000180000040D460000
3800000F130000003800A00004000000
180000050CFA0000180000091CF50000
0800000F000000000800000F00000000
01404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
40404040404040404040404040404040
3C1F0000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
554F0000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000