6

Prism Quest: Dimension Mastery

ZX Spectrum • Phase 1 • Tier 1

Add dimensional puzzle mastery and progression to Prism Quest! Create puzzle completion tracking and dimensional advancement while learning conditional branching through puzzle logic and mastery systems.

⚪ easy
⏱️ 30-45 minutes
đź’» Code Examples
🛠️ Exercise
🎯

Learning Objectives

  • Create dimensional puzzle mastery systems with completion tracking
  • Add dimensional advancement and puzzle difficulty progression
  • Learn conditional branching through puzzle logic and mastery checking
  • Build dimensional rewards and achievement systems with branching logic
  • Experience creative Spectrum progression with spectacular dimensional celebration
đź§ 

Key Concepts

Dimensional puzzle mastery and completion tracking systems Conditional branching for puzzle logic and dimensional progression control Puzzle difficulty scaling and dimensional advancement systems Dimensional achievement tracking and mastery reward systems Creative Spectrum progression with attribute-based celebration effects

Lesson 6: Prism Quest - Dimension Mastery

Your dimensional puzzles need satisfying mastery! In the last lesson, you added spectacular attribute magic with dynamic color cycling to your dimensional world. Today, you’ll create dimensional puzzle mastery and progression systems - completion tracking, dimensional advancement, and mastery rewards that transform your attribute showcase into an engaging dimensional progression experience!

Your Dimension Mastery Awakens

Let’s start with the magic - adding dimensional puzzle mastery and progression systems to your attribute world:

; Prism Quest - Dimension Mastery Creation
    ORG $8000
    
start:
    ; Set up enhanced dimensional attribute world from Lessons 1-5
    CALL clear_screen
    CALL draw_dimensional_maze
    CALL init_attribute_magic
    CALL create_color_patterns
    
    ; Initialize navigator from previous lessons
    LD BC, $0205        ; Navigator position: B=X(2), C=Y(5)
    LD (navigator_x), BC ; Store in memory
    
    ; Initialize dimensional mastery system
    CALL init_mastery_system
    
    ; Initialize puzzle completion tracking
    CALL init_puzzle_tracking
    
    ; Set up dimensional progression
    CALL init_dimension_progression
    
    ; Initialize mastery achievement system
    CALL init_mastery_achievements
    
    ; Main dimensional mastery loop
main_loop:
    CALL read_navigator_input
    CALL update_navigator_position
    CALL update_attribute_magic
    CALL check_puzzle_completion
    CALL update_dimensional_mastery
    CALL check_dimension_progression
    CALL update_mastery_effects
    JR main_loop

; Initialize dimensional mastery system
init_mastery_system:
    ; Set up mastery state variables
    LD A, $00           ; No mastery achieved initially
    LD (mastery_flag), A ; Mastery flag
    LD (dimension_complete), A ; Dimension complete flag
    LD (quest_complete), A ; Quest complete flag
    
    ; Initialize mastery conditions
    LD A, $05           ; Puzzles required for dimension mastery
    LD (puzzles_required), A ; Puzzles to solve counter
    LD A, $00           ; Puzzles solved this dimension
    LD (puzzles_solved), A ; Current puzzles solved
    
    ; Set mastery timing
    LD A, $00           ; Mastery sequence timer
    LD (mastery_timer), A ; Mastery timer
    LD A, $60           ; Mastery sequence duration (96 frames)
    LD (mastery_duration), A ; Mastery duration constant
    
    ; Initialize mastery rewards
    LD A, $10           ; Mastery attribute bonus
    LD (attribute_reward), A ; Attribute reward amount
    LD A, $08           ; Mastery pattern bonus
    LD (pattern_reward), A ; Pattern reward amount
    
    RET

; Initialize puzzle completion tracking
init_puzzle_tracking:
    ; Set up puzzle tracking variables
    LD A, $00           ; Clear puzzle completion flags
    LD (puzzle_1_complete), A ; Puzzle 1 status
    LD (puzzle_2_complete), A ; Puzzle 2 status
    LD (puzzle_3_complete), A ; Puzzle 3 status
    LD (puzzle_4_complete), A ; Puzzle 4 status
    LD (puzzle_5_complete), A ; Puzzle 5 status
    
    ; Initialize puzzle difficulty tracking
    LD A, $01           ; Base puzzle difficulty
    LD (current_difficulty), A ; Current difficulty level
    LD A, $00           ; Puzzle attempt counter
    LD (puzzle_attempts), A ; Attempts for current puzzle
    
    ; Set puzzle scoring
    LD A, $0A           ; Points per puzzle solved
    LD (puzzle_points), A ; Puzzle base points
    LD A, $05           ; Bonus for quick solve
    LD (speed_bonus), A ; Speed completion bonus
    LD A, $14           ; Bonus for perfect solve
    LD (perfect_bonus), A ; Perfect completion bonus
    
    RET

; Initialize dimensional progression system
init_dimension_progression:
    ; Set up dimension variables
    LD A, $01           ; Starting dimension
    LD (current_dimension), A ; Current dimension level
    LD A, $05           ; Maximum dimensions
    LD (max_dimensions), A ; Maximum dimension level
    
    ; Initialize dimensional scaling
    LD A, $03           ; Starting puzzle complexity
    LD (puzzle_complexity), A ; Puzzles per dimension
    LD A, $02           ; Starting pattern count
    LD (pattern_count), A ; Patterns per puzzle
    LD A, $04           ; Starting color count
    LD (color_count), A ; Colors per pattern
    
    ; Set dimension requirements
    LD A, $05           ; Puzzles to solve per dimension
    LD (dimension_requirement), A ; Dimension requirement
    
    RET

; Initialize mastery achievement system
init_mastery_achievements:
    ; Set up achievement flags
    LD A, $00           ; No achievements unlocked initially
    LD (first_mastery), A ; First puzzle mastery achievement
    LD (perfect_dimension), A ; Perfect dimension achievement (no mistakes)
    LD (speed_master), A ; Speed mastery achievement
    LD (pattern_master), A ; Pattern mastery achievement
    
    ; Initialize achievement thresholds
    LD A, $32           ; Speed mastery threshold (50 frames)
    LD (speed_threshold), A ; Speed mastery requirement
    LD A, $10           ; Pattern mastery threshold (16 patterns)
    LD (pattern_threshold), A ; Pattern mastery requirement
    
    ; Set achievement rewards
    LD A, $05           ; Achievement attribute bonus
    LD (achievement_attribute), A ; Achievement attribute reward
    LD A, $0A           ; Achievement pattern bonus
    LD (achievement_pattern), A ; Achievement pattern reward
    
    RET

; Check puzzle completion using conditional branching
check_puzzle_completion:
    ; Check if mastery flag already set
    LD A, (mastery_flag) ; Load mastery flag
    CP $00              ; Compare with zero
    JR NZ, mastery_sequence ; Jump if mastery in progress
    
    ; Check current puzzle completion
    LD A, (navigator_x) ; Load navigator X position
    CP $0A              ; Check if at puzzle 1 position
    JR Z, check_puzzle_1 ; Jump if at puzzle 1
    CP $14              ; Check if at puzzle 2 position
    JR Z, check_puzzle_2 ; Jump if at puzzle 2
    CP $1E              ; Check if at puzzle 3 position
    JR Z, check_puzzle_3 ; Jump if at puzzle 3
    CP $28              ; Check if at puzzle 4 position
    JR Z, check_puzzle_4 ; Jump if at puzzle 4
    CP $32              ; Check if at puzzle 5 position
    JR Z, check_puzzle_5 ; Jump if at puzzle 5
    JR completion_check_done ; Jump if not at puzzle position
    
check_puzzle_1:
    ; Check if puzzle 1 already completed
    LD A, (puzzle_1_complete) ; Load completion status
    CP $00              ; Check if not completed
    JR NZ, completion_check_done ; Jump if already completed
    
    ; Check puzzle 1 solution conditions
    CALL check_puzzle_1_solution
    CP $01              ; Check if solution correct
    JR NZ, completion_check_done ; Jump if solution incorrect
    
    ; Puzzle 1 completed!
    CALL complete_puzzle_1
    JR trigger_puzzle_mastery
    
check_puzzle_2:
    ; Similar check for puzzle 2
    LD A, (puzzle_2_complete) ; Load completion status
    CP $00              ; Check if not completed
    JR NZ, completion_check_done ; Jump if already completed
    
    CALL check_puzzle_2_solution
    CP $01              ; Check if solution correct
    JR NZ, completion_check_done ; Jump if solution incorrect
    
    CALL complete_puzzle_2
    JR trigger_puzzle_mastery
    
check_puzzle_3:
    ; Similar check for puzzle 3
    LD A, (puzzle_3_complete) ; Load completion status
    CP $00              ; Check if not completed
    JR NZ, completion_check_done ; Jump if already completed
    
    CALL check_puzzle_3_solution
    CP $01              ; Check if solution correct
    JR NZ, completion_check_done ; Jump if solution incorrect
    
    CALL complete_puzzle_3
    JR trigger_puzzle_mastery
    
check_puzzle_4:
    ; Similar check for puzzle 4
    LD A, (puzzle_4_complete) ; Load completion status
    CP $00              ; Check if not completed
    JR NZ, completion_check_done ; Jump if already completed
    
    CALL check_puzzle_4_solution
    CP $01              ; Check if solution correct
    JR NZ, completion_check_done ; Jump if solution incorrect
    
    CALL complete_puzzle_4
    JR trigger_puzzle_mastery
    
check_puzzle_5:
    ; Similar check for puzzle 5
    LD A, (puzzle_5_complete) ; Load completion status
    CP $00              ; Check if not completed
    JR NZ, completion_check_done ; Jump if already completed
    
    CALL check_puzzle_5_solution
    CP $01              ; Check if solution correct
    JR NZ, completion_check_done ; Jump if solution incorrect
    
    CALL complete_puzzle_5
    JR trigger_puzzle_mastery
    
trigger_puzzle_mastery:
    ; Increment puzzles solved counter
    LD A, (puzzles_solved) ; Load current count
    INC A               ; Increment count
    LD (puzzles_solved), A ; Store updated count
    
    ; Check for dimension mastery
    LD B, A             ; Store count in B
    LD A, (puzzles_required) ; Load required count
    CP B                ; Compare required with solved
    JR NZ, completion_check_done ; Jump if not enough puzzles solved
    
    ; Dimension mastery achieved!
    CALL trigger_dimension_mastery
    
mastery_sequence:
    ; Handle mastery sequence timing
    CALL update_mastery_sequence
    
completion_check_done:
    RET

; Complete individual puzzles with conditional rewards
complete_puzzle_1:
    ; Set puzzle 1 complete flag
    LD A, $01           ; Set complete flag
    LD (puzzle_1_complete), A ; Store completion status
    
    ; Award puzzle completion rewards
    CALL award_puzzle_rewards
    
    ; Check for speed completion bonus
    LD A, (puzzle_attempts) ; Load attempt count
    CP $01              ; Check if solved on first attempt
    JR NZ, check_puzzle_1_perfect ; Jump if not first attempt
    
    ; First attempt bonus!
    CALL award_first_attempt_bonus
    
check_puzzle_1_perfect:
    ; Check for perfect solution (no attribute mistakes)
    CALL check_perfect_solution
    CP $01              ; Check if perfect
    JR NZ, puzzle_1_done ; Jump if not perfect
    
    ; Perfect solution achieved!
    CALL award_perfect_solution_bonus
    
puzzle_1_done:
    ; Play puzzle completion sound
    CALL play_puzzle_complete_sound
    
    RET

complete_puzzle_2:
    ; Similar completion logic for puzzle 2
    LD A, $01           ; Set complete flag
    LD (puzzle_2_complete), A ; Store completion status
    CALL award_puzzle_rewards
    
    ; Check for advanced puzzle bonuses
    LD A, (current_difficulty) ; Load difficulty
    CP $02              ; Check if advanced difficulty
    JR C, puzzle_2_done ; Jump if basic difficulty
    
    ; Advanced difficulty bonus
    CALL award_advanced_difficulty_bonus
    
puzzle_2_done:
    CALL play_puzzle_complete_sound
    RET

complete_puzzle_3:
    ; Enhanced completion for puzzle 3 (mid-dimension)
    LD A, $01           ; Set complete flag
    LD (puzzle_3_complete), A ; Store completion status
    CALL award_puzzle_rewards
    
    ; Mid-dimension checkpoint bonus
    CALL award_checkpoint_bonus
    
    CALL play_puzzle_complete_sound
    RET

complete_puzzle_4:
    ; Advanced completion for puzzle 4
    LD A, $01           ; Set complete flag
    LD (puzzle_4_complete), A ; Store completion status
    CALL award_puzzle_rewards
    
    ; Near-mastery bonus for puzzle 4
    CALL award_near_mastery_bonus
    
    CALL play_puzzle_complete_sound
    RET

complete_puzzle_5:
    ; Final puzzle completion (triggers dimension mastery)
    LD A, $01           ; Set complete flag
    LD (puzzle_5_complete), A ; Store completion status
    CALL award_puzzle_rewards
    
    ; Final puzzle special bonus
    CALL award_final_puzzle_bonus
    
    CALL play_puzzle_complete_sound
    RET

; Trigger dimension mastery with conditional celebration
trigger_dimension_mastery:
    ; Set mastery flags
    LD A, $01           ; Set mastery flag
    LD (mastery_flag), A ; Store mastery state
    LD (dimension_complete), A ; Set dimension complete flag
    
    ; Award base mastery rewards
    CALL award_mastery_rewards
    
    ; Check for perfect dimension bonus (no puzzle mistakes)
    LD A, (puzzle_attempts) ; Load total attempts
    LD B, A             ; Store in B
    LD A, (puzzles_solved) ; Load puzzles solved
    CP B                ; Compare puzzles solved with attempts
    JR NZ, check_speed_mastery ; Jump if mistakes were made
    
    ; Perfect dimension achieved!
    LD A, $01           ; Set perfect achievement
    LD (perfect_dimension), A ; Store perfect flag
    CALL award_perfect_dimension_bonus
    
check_speed_mastery:
    ; Check for speed mastery bonus
    LD A, (mastery_timer) ; Load completion time
    LD B, A             ; Store in B
    LD A, (speed_threshold) ; Load speed threshold
    CP B                ; Compare threshold with time
    JR C, normal_mastery ; Jump if too slow
    
    ; Speed mastery achieved!
    LD A, $01           ; Set speed achievement
    LD (speed_master), A ; Store speed flag
    CALL award_speed_mastery_bonus
    JR start_mastery_effects
    
normal_mastery:
    ; Standard mastery rewards only
    CALL award_standard_mastery_rewards
    
start_mastery_effects:
    ; Initialize mastery visual effects
    LD A, (mastery_duration) ; Load mastery duration
    LD (mastery_timer), A ; Set mastery timer
    
    ; Play dimension mastery sound
    CALL play_dimension_mastery_sound
    
    RET

; Update dimensional mastery system with conditional logic
update_dimensional_mastery:
    ; Update puzzle attempt tracking
    LD A, (navigator_input) ; Check if input received
    CP $00              ; Check if no input
    JR Z, mastery_update_done ; Jump if no input
    
    ; Input received - increment attempt counter
    LD A, (puzzle_attempts) ; Load current attempts
    INC A               ; Increment attempts
    LD (puzzle_attempts), A ; Store updated attempts
    
    ; Check for too many attempts (failure condition)
    CP $0A              ; Check if 10 or more attempts
    JR C, mastery_update_done ; Jump if under limit
    
    ; Too many attempts - reset current puzzle
    CALL reset_current_puzzle
    
mastery_update_done:
    RET

; Check dimension progression conditions
check_dimension_progression:
    ; Check if dimension complete flag is set
    LD A, (dimension_complete) ; Load dimension complete flag
    CP $00              ; Check if not complete
    JR Z, progression_check_done ; Jump if dimension not complete
    
    ; Check if mastery sequence finished
    LD A, (mastery_timer) ; Load mastery timer
    CP $00              ; Check if timer finished
    JR NZ, progression_check_done ; Jump if mastery sequence still running
    
    ; Dimension complete - check for quest completion
    LD A, (current_dimension) ; Load current dimension
    LD B, A             ; Store in B
    LD A, (max_dimensions) ; Load maximum dimensions
    CP B                ; Compare max with current
    JR Z, trigger_quest_completion ; Jump if at max dimension
    JR C, trigger_quest_completion ; Jump if beyond max dimension
    
    ; Advance to next dimension
    CALL advance_to_next_dimension
    JR progression_check_done
    
trigger_quest_completion:
    ; Quest completed!
    LD A, $01           ; Set quest complete flag
    LD (quest_complete), A ; Store completion state
    
    ; Trigger final mastery sequence
    CALL trigger_final_mastery
    
progression_check_done:
    RET

; Advance to next dimension with difficulty scaling
advance_to_next_dimension:
    ; Increment dimension
    LD A, (current_dimension) ; Load current dimension
    INC A               ; Advance dimension
    LD (current_dimension), A ; Store new dimension
    
    ; Scale difficulty based on dimension
    CP $03              ; Check if dimension 3 or higher
    JR C, normal_scaling ; Jump if low dimension
    
    ; High dimension scaling
    LD A, (puzzle_complexity) ; Load complexity
    INC A               ; Increase complexity
    LD (puzzle_complexity), A ; Store increased complexity
    LD A, (pattern_count) ; Load pattern count
    INC A               ; Increase patterns
    LD (pattern_count), A ; Store increased patterns
    JR reset_dimension_state
    
normal_scaling:
    ; Normal scaling for early dimensions
    LD A, (color_count) ; Load color count
    INC A               ; Increase colors
    LD (color_count), A ; Store increased colors
    
reset_dimension_state:
    ; Reset dimension-specific variables
    LD A, $00           ; Clear puzzles solved
    LD (puzzles_solved), A ; Reset solve counter
    LD A, $00           ; Clear mastery flags
    LD (mastery_flag), A ; Clear mastery flag
    LD (dimension_complete), A ; Clear dimension complete flag
    
    ; Reset all puzzle completion flags
    LD (puzzle_1_complete), A ; Reset puzzle 1
    LD (puzzle_2_complete), A ; Reset puzzle 2
    LD (puzzle_3_complete), A ; Reset puzzle 3
    LD (puzzle_4_complete), A ; Reset puzzle 4
    LD (puzzle_5_complete), A ; Reset puzzle 5
    
    ; Reset puzzle attempts counter
    LD (puzzle_attempts), A ; Clear attempts
    
    ; Award dimension advancement bonus
    LD A, (pattern_reward) ; Load dimension completion bonus
    CALL award_mastery_points
    
    ; Reinitialize puzzles for new dimension
    CALL create_dimension_puzzles
    
    ; Play dimension advancement sound
    CALL play_dimension_advance_sound
    
    RET

; Update mastery sequence with conditional effects
update_mastery_sequence:
    ; Check if mastery sequence active
    LD A, (mastery_timer) ; Load mastery timer
    CP $00              ; Check if finished
    JR Z, mastery_sequence_done ; Jump if sequence finished
    
    ; Update mastery timer
    DEC A               ; Decrement mastery timer
    LD (mastery_timer), A ; Store updated timer
    
    ; Create mastery visual effects based on timer
    LD B, A             ; Store timer in B
    LD A, $30           ; Half sequence duration
    CP B                ; Compare with current timer
    JR C, mastery_second_half ; Jump if second half
    
    ; First half - bright attribute flashing effects
    LD A, B             ; Load timer
    AND $04             ; Mask for flashing
    JR Z, mastery_bright ; Jump for bright frame
    
    ; Dim frame
    LD A, $41           ; Dim attribute combination
    LD (ATTR_FILE), A   ; Store in attribute memory
    JR mastery_effect_done
    
mastery_bright:
    ; Bright frame
    LD A, $47           ; Bright attribute combination
    LD (ATTR_FILE), A   ; Store in attribute memory
    JR mastery_effect_done
    
mastery_second_half:
    ; Second half - spectacular color cycling
    LD A, B             ; Load timer
    AND $07             ; Mask for color cycle
    ADD A, $42          ; Offset attributes
    LD (ATTR_FILE), A   ; Store cycling attributes
    
mastery_effect_done:
    RET
    
mastery_sequence_done:
    ; Mastery sequence finished - restore normal attributes
    LD A, $47           ; Normal bright attribute
    LD (ATTR_FILE), A   ; Restore normal attributes
    
    RET

; Award various mastery rewards using conditional logic
award_mastery_rewards:
    ; Award base attribute reward
    LD A, (attribute_reward) ; Load attribute bonus
    CALL award_mastery_points
    
    ; Award base pattern reward
    LD A, (pattern_reward) ; Load pattern bonus
    CALL award_mastery_points
    
    RET

award_perfect_dimension_bonus:
    ; Double mastery bonus for perfect dimension
    LD A, (attribute_reward) ; Load base bonus
    SLA A               ; Double it (shift left)
    CALL award_mastery_points
    
    ; Award achievement attribute bonus
    LD A, (achievement_attribute) ; Load achievement attribute bonus
    CALL award_mastery_points
    
    RET

award_speed_mastery_bonus:
    ; Triple mastery bonus for speed completion
    LD A, (attribute_reward) ; Load base bonus
    LD B, A             ; Store in B
    SLA A               ; Double it
    ADD A, B            ; Add base again (triple total)
    CALL award_mastery_points
    
    RET

award_standard_mastery_rewards:
    ; Standard mastery bonus only
    LD A, (attribute_reward) ; Load mastery attribute bonus
    CALL award_mastery_points
    
    RET

; Award mastery points (simplified scoring system)
award_mastery_points:
    ; A register contains points to award
    ; Add to dimensional mastery score (simplified)
    LD B, A             ; Store points in B
    LD A, (mastery_score) ; Load current score
    ADD A, B            ; Add new points
    LD (mastery_score), A ; Store updated score
    
    ; Check for mastery score milestones
    CP $32              ; Check for 50 point milestone
    JR C, score_award_done ; Jump if below milestone
    
    ; Milestone reached - award bonus
    CALL award_milestone_bonus
    
score_award_done:
    RET

; Puzzle solution checking (simplified examples)
check_puzzle_1_solution:
    ; Check if navigator positioned correctly for puzzle 1
    LD A, (navigator_y) ; Load navigator Y position
    CP $05              ; Check if at solution position
    JR NZ, puzzle_1_incorrect ; Jump if wrong position
    
    ; Check attribute state for correct pattern
    LD A, (ATTR_FILE+64) ; Check specific attribute cell
    CP $46              ; Check for correct attribute combination
    JR NZ, puzzle_1_incorrect ; Jump if wrong attribute
    
    ; Puzzle 1 solved correctly!
    LD A, $01           ; Return success
    RET
    
puzzle_1_incorrect:
    LD A, $00           ; Return failure
    RET

check_puzzle_2_solution:
    ; More complex solution for puzzle 2
    LD A, (navigator_y) ; Load navigator Y position
    CP $08              ; Check solution Y position
    JR NZ, puzzle_2_incorrect ; Jump if wrong Y position
    
    LD A, (navigator_x) ; Load navigator X position
    CP $14              ; Check solution X position
    JR NZ, puzzle_2_incorrect ; Jump if wrong X position
    
    ; Check multiple attribute states
    LD A, (ATTR_FILE+128) ; Check attribute cell 1
    CP $45              ; Check for pattern 1
    JR NZ, puzzle_2_incorrect ; Jump if wrong
    
    LD A, (ATTR_FILE+129) ; Check attribute cell 2
    CP $43              ; Check for pattern 2
    JR NZ, puzzle_2_incorrect ; Jump if wrong
    
    ; Puzzle 2 solved correctly!
    LD A, $01           ; Return success
    RET
    
puzzle_2_incorrect:
    LD A, $00           ; Return failure
    RET

; Simplified puzzle 3, 4, 5 solutions
check_puzzle_3_solution:
    ; Complex multi-pattern solution
    LD A, $01           ; Simplified - always correct for demo
    RET

check_puzzle_4_solution:
    ; Advanced pattern matching
    LD A, $01           ; Simplified - always correct for demo
    RET

check_puzzle_5_solution:
    ; Master-level solution checking
    LD A, $01           ; Simplified - always correct for demo
    RET

; Sound effects for dimensional mastery
play_puzzle_complete_sound:
    ; Create puzzle completion sound using BEEP
    LD A, $50           ; Frequency for puzzle sound
    OUT ($FE), A        ; Output to speaker
    LD B, $10           ; Duration counter
puzzle_sound_loop:
    DJNZ puzzle_sound_loop ; Loop for duration
    RET

play_dimension_mastery_sound:
    ; Create dimension mastery fanfare
    LD A, $30           ; Low frequency start
    OUT ($FE), A        ; Output to speaker
    LD B, $20           ; Duration counter
mastery_sound_loop_1:
    DJNZ mastery_sound_loop_1 ; Loop for duration
    
    LD A, $60           ; High frequency finish
    OUT ($FE), A        ; Output to speaker
    LD B, $20           ; Duration counter
mastery_sound_loop_2:
    DJNZ mastery_sound_loop_2 ; Loop for duration
    RET

play_dimension_advance_sound:
    ; Create dimension advancement sound
    LD A, $40           ; Medium frequency
    OUT ($FE), A        ; Output to speaker
    LD B, $30           ; Longer duration
advance_sound_loop:
    DJNZ advance_sound_loop ; Loop for duration
    RET

; Additional helper functions
award_puzzle_rewards:
    LD A, (puzzle_points) ; Load base puzzle points
    CALL award_mastery_points
    RET

award_first_attempt_bonus:
    LD A, (speed_bonus) ; Load speed bonus
    CALL award_mastery_points
    RET

award_perfect_solution_bonus:
    LD A, (perfect_bonus) ; Load perfect bonus
    CALL award_mastery_points
    RET

award_advanced_difficulty_bonus:
    LD A, $08           ; Advanced difficulty bonus
    CALL award_mastery_points
    RET

award_checkpoint_bonus:
    LD A, $0C           ; Mid-dimension checkpoint bonus
    CALL award_mastery_points
    RET

award_near_mastery_bonus:
    LD A, $0E           ; Near-mastery bonus
    CALL award_mastery_points
    RET

award_final_puzzle_bonus:
    LD A, $12           ; Final puzzle bonus
    CALL award_mastery_points
    RET

award_milestone_bonus:
    LD A, $14           ; Milestone achievement bonus
    CALL award_mastery_points
    RET

reset_current_puzzle:
    ; Reset puzzle state after too many attempts
    LD A, $00           ; Clear attempts
    LD (puzzle_attempts), A ; Reset attempts counter
    
    ; Reset navigator position
    LD BC, $0205        ; Reset position
    LD (navigator_x), BC ; Store reset position
    RET

create_dimension_puzzles:
    ; Initialize puzzles for new dimension (simplified)
    ; This would create new puzzle patterns based on current difficulty
    RET

trigger_final_mastery:
    ; Final quest completion sequence
    LD A, $78           ; Extended mastery duration (120 frames)
    LD (mastery_timer), A ; Set extended mastery timer
    
    ; Play final mastery sound
    CALL play_final_mastery_sound
    
    RET

play_final_mastery_sound:
    ; Create final quest completion fanfare
    LD A, $20           ; Very low frequency start
    OUT ($FE), A        ; Output to speaker
    LD B, $40           ; Extended duration
final_sound_loop_1:
    DJNZ final_sound_loop_1 ; Loop for duration
    
    LD A, $70           ; Very high frequency finish
    OUT ($FE), A        ; Output to speaker
    LD B, $40           ; Extended duration
final_sound_loop_2:
    DJNZ final_sound_loop_2 ; Loop for duration
    RET

; Data storage for mastery system
mastery_flag:           DEFB $00
dimension_complete:     DEFB $00
quest_complete:         DEFB $00
puzzles_required:       DEFB $05
puzzles_solved:         DEFB $00
mastery_timer:          DEFB $00
mastery_duration:       DEFB $60
attribute_reward:       DEFB $10
pattern_reward:         DEFB $08

puzzle_1_complete:      DEFB $00
puzzle_2_complete:      DEFB $00
puzzle_3_complete:      DEFB $00
puzzle_4_complete:      DEFB $00
puzzle_5_complete:      DEFB $00
current_difficulty:     DEFB $01
puzzle_attempts:        DEFB $00
puzzle_points:          DEFB $0A
speed_bonus:            DEFB $05
perfect_bonus:          DEFB $14

current_dimension:      DEFB $01
max_dimensions:         DEFB $05
puzzle_complexity:      DEFB $03
pattern_count:          DEFB $02
color_count:            DEFB $04
dimension_requirement:  DEFB $05

first_mastery:          DEFB $00
perfect_dimension:      DEFB $00
speed_master:           DEFB $00
pattern_master:         DEFB $00
speed_threshold:        DEFB $32
pattern_threshold:      DEFB $10
achievement_attribute:  DEFB $05
achievement_pattern:    DEFB $0A

navigator_x:            DEFB $02
navigator_y:            DEFB $05
navigator_input:        DEFB $00
mastery_score:          DEFB $00

Run It Right Now!

Don’t wait - let’s see your dimensional mastery in action:

# Save as prism6.tap, then:
# Load into ZX Spectrum emulator (Fuse, etc.)
# You should see: Dimensional puzzle mastery with completion tracking and progression!

You should see: Your dimensional attribute world from Lessons 1-5, plus comprehensive dimensional puzzle mastery with completion tracking, dimensional advancement, achievement systems, and spectacular dimensional celebration sequences that create engaging progression gameplay!

What Just Happened? The Magic Behind Dimensional Mastery Systems

Now that you’ve experienced dimensional mastery, let’s understand how conditional branching orchestrated this dynamic dimensional progression system.

Conditional Branching: Your Dimensional Mastery System

The most important thing to understand: conditional branching enables sophisticated puzzle logic and dimensional state management. In your dimensional mastery code:

Puzzle Completion Checking: Multiple solution paths with branching logic

check_puzzle_completion:
    LD A, (navigator_x) ; Load navigator X position
    CP $0A              ; Check if at puzzle 1 position
    JR Z, check_puzzle_1 ; Jump if at puzzle 1
    CP $14              ; Check if at puzzle 2 position
    JR Z, check_puzzle_2 ; Jump if at puzzle 2

Achievement Logic: Conditional rewards based on performance

check_speed_mastery:
    LD A, (mastery_timer) ; Load completion time
    LD B, A             ; Store in B
    LD A, (speed_threshold) ; Load speed threshold
    CP B                ; Compare threshold with time
    JR C, normal_mastery ; Jump if too slow

Dimensional Mastery Examples Using Conditional Branching:

TechniqueExampleUse Case
Puzzle CheckingCP / JR Z puzzleCheck multiple puzzle positions
Achievement LogicCP / JR C achievementAward conditional bonuses
State ManagementJR Z / JR NZ stateControl dimensional progression flow

Why Conditional Branching Matters for Dimensional Systems

Multiple Solution Paths - Essential for engaging puzzle progression:

check_puzzle_1_solution:
    LD A, (navigator_y) ; Load navigator Y position
    CP $05              ; Check if at solution position
    JR NZ, puzzle_1_incorrect ; Jump if wrong position
    
    ; Check attribute state for correct pattern
    LD A, (ATTR_FILE+64) ; Check specific attribute cell
    CP $46              ; Check for correct attribute combination

Dynamic Reward Systems - Handles conditional dimensional bonuses:

trigger_dimension_mastery:
    LD A, (puzzle_attempts) ; Load total attempts
    LD B, A             ; Store in B
    LD A, (puzzles_solved) ; Load puzzles solved
    CP B                ; Compare puzzles solved with attempts
    JR NZ, check_speed_mastery ; Jump if mistakes were made
    
    ; Perfect dimension achieved!
    CALL award_perfect_dimension_bonus

Progressive Difficulty - Scales based on dimensional progress:

advance_to_next_dimension:
    LD A, (current_dimension) ; Load current dimension
    CP $03              ; Check if dimension 3 or higher
    JR C, normal_scaling ; Jump if low dimension
    
    ; High dimension scaling
    LD A, (puzzle_complexity) ; Load complexity
    INC A               ; Increase complexity

Practice: Create Advanced Dimensional Mechanics

Let’s enhance your dimensional system with advanced mastery features:

    ; Create multi-tier dimensional achievement system
    CALL init_advanced_dimensional_achievements
    
init_advanced_dimensional_achievements:
    ; Set up tier-based dimensional achievements
    LD A, $00           ; No tiers unlocked initially
    LD (dimensional_tier_1), A ; Basic dimensional achievements
    LD (dimensional_tier_2), A ; Advanced dimensional achievements  
    LD (dimensional_tier_3), A ; Master dimensional achievements
    
    ; Initialize tier requirements
    LD A, $05           ; Tier 1 requirement
    LD (dimensional_tier_1_threshold), A
    LD A, $14           ; Tier 2 requirement (20)
    LD (dimensional_tier_2_threshold), A
    LD A, $32           ; Tier 3 requirement (50)
    LD (dimensional_tier_3_threshold), A
    
    RET

check_dimensional_achievement_tiers:
    ; Check current mastery score for tier progression
    LD A, (mastery_score) ; Load mastery score
    LD B, A             ; Store in B
    LD A, (dimensional_tier_1_threshold) ; Load tier 1 threshold
    CP B                ; Compare with current score
    JR NC, tier_check_done ; Jump if below tier 1
    
    ; Tier 1 unlocked
    LD A, (dimensional_tier_1) ; Check if already unlocked
    CP $00              ; Check if not unlocked
    JR NZ, check_dimensional_tier_2 ; Jump if already unlocked
    
    LD A, $01           ; Unlock tier 1
    LD (dimensional_tier_1), A
    CALL award_dimensional_tier_1_bonus
    
check_dimensional_tier_2:
    LD A, (mastery_score) ; Load mastery score
    LD B, A             ; Store in B
    LD A, (dimensional_tier_2_threshold) ; Load tier 2 threshold
    CP B                ; Compare with current score
    JR NC, tier_check_done ; Jump if below tier 2
    
    ; Tier 2 unlocked
    LD A, (dimensional_tier_2) ; Check if already unlocked
    CP $00              ; Check if not unlocked
    JR NZ, check_dimensional_tier_3 ; Jump if already unlocked
    
    LD A, $01           ; Unlock tier 2
    LD (dimensional_tier_2), A
    CALL award_dimensional_tier_2_bonus
    
check_dimensional_tier_3:
    LD A, (mastery_score) ; Load mastery score
    LD B, A             ; Store in B
    LD A, (dimensional_tier_3_threshold) ; Load tier 3 threshold
    CP B                ; Compare with current score
    JR NC, tier_check_done ; Jump if below tier 3
    
    ; Tier 3 unlocked
    LD A, (dimensional_tier_3) ; Check if already unlocked
    CP $00              ; Check if not unlocked
    JR NZ, tier_check_done ; Jump if already unlocked
    
    LD A, $01           ; Unlock tier 3
    LD (dimensional_tier_3), A
    CALL award_dimensional_tier_3_bonus
    
tier_check_done:
    RET

; Dimensional achievement data
dimensional_tier_1:             DEFB $00
dimensional_tier_2:             DEFB $00
dimensional_tier_3:             DEFB $00
dimensional_tier_1_threshold:   DEFB $05
dimensional_tier_2_threshold:   DEFB $14
dimensional_tier_3_threshold:   DEFB $32

Run it again and experience advanced multi-tier dimensional achievement systems!

Visual Progress Check

After running your enhanced code, you should see:

  • Your original dimensional attribute world with color cycling as the foundation
  • Puzzle completion tracking with dimensional mastery conditions
  • Dimensional progression with increasing puzzle complexity
  • Achievement notifications and tier unlocking systems
  • Spectacular dimensional celebration sequences with attribute cycling effects
  • Satisfying mastery sequences with visual and audio dimensional celebration

Take a screenshot! Your dimensional world now has complete puzzle mastery progression.

What You’ve Accomplished

In this lesson, you’ve:

âś… Created dimensional puzzle mastery systems with multiple completion paths using conditional branching
âś… Learned conditional branching through puzzle logic and dimensional state management
âś… Built dimensional tracking systems with mastery scoring and achievement bonuses
âś… Used comparison operations for puzzle solution checking and threshold management
âś… Used branching logic for progressive dimensional difficulty scaling and reward systems
âś… Used state management for dimensional advancement and quest completion sequences

More importantly, you’ve experienced creative Spectrum progression programming - creating satisfying dimensional mastery systems with spectacular attribute-based celebration mechanics.

Dimensional Mastery Game Architecture

Why This Approach Matters:

Your dimensional mastery system demonstrates core puzzle completion programming:

  • Multi-solution puzzle logic using branching for flexible completion conditions
  • Dynamic dimensional reward systems with conditional bonuses based on mastery performance
  • Progressive dimensional difficulty scaling that adapts to player advancement
  • Achievement tracking systems providing long-term dimensional engagement goals
  • Creative Spectrum presentation with attribute manipulation celebration effects and dimensional audio

These same techniques enabled the satisfying dimensional progression that made Spectrum games legendary for creative constraint-based gameplay advancement.

Looking Ahead: Your Dimensional Journey

Next lesson, you’ll add the most essential element - dimensional power-ups and enhancements! You’ll learn:

  • How to create collectible dimensional artifacts and attribute upgrades
  • Building temporary and permanent dimensional enhancement systems
  • Adding visual dimensional upgrade effects and enhancement feedback
  • Creating balanced dimensional progression through upgrade mechanics

By Lesson 8, you’ll have complete dimensional game mechanics with full puzzle mastery, progression, power-ups, and victory conditions in a finished Spectrum dimensional experience.

Ready to Continue?

Your dimensional world now celebrates with spectacular mastery sequences! Dimensional puzzle completion and progression systems create the engaging advancement that defines classic dimensional gaming achievement. The next lesson will add dimensional power-ups to create complete enhancement experiences.

But first, achieve mastery in the dimensional realm. You’ve just implemented comprehensive dimensional mastery systems using authentic Z80 conditional branching. This demonstrates the dimensional progression gameplay programming that made Spectrum games famous for creative constraint-based advancement mechanics.

Welcome to dimensional mastery programming!


Quick Reference: Today’s Dimensional Programming Instructions

  • CP #value: Compare for puzzle solution checking and dimensional threshold management
  • JR C label: Jump if Carry (less than - for dimensional threshold checking)
  • JR NC label: Jump if No Carry (greater/equal - for dimensional achievement unlocking)
  • JR Z label: Jump if Zero (exact dimensional condition matching)
  • JR NZ label: Jump if Not Zero (dimensional state change detection)

Save this reference - you’ll use these conditional branching techniques to manage all your dimensional mastery and achievement systems!