Source Code file: netherearth-annotated.asm

Address | Position in Binary | Size | Timing | Assembled | Code

#0000

#0000

    ; --------------------------------

#0000

#0000

    ;

#0000

#0000

    ; "Nether Earth" by Argus Press Software

#0000

#0000

    ; Disassembled by Santiago Ontañón in 2022

#0000

#0000

    ;

#0000

#0000

    ; --------------------------------

#0000

#0000

    ;

#0000

#0000

    ; Notes:

#0000

#0000

    ;

#0000

#0000

    ; - All the symbol names and comments in this file are my own interpretation of the original source

#0000

#0000

    ;   code, they could be wrong. So, take them all with a grain of salt! And if you see any errors,

#0000

#0000

    ;   please report!

#0000

#0000

    ;

#0000

#0000

    ; - Game binary disassembled using MDL: https://github.com/santiontanon/mdlz80optimizer

#0000

#0000

    ;

#0000

#0000

    ; - I decided to prefix each label by their address, e.g. "La600_start" instead of just "start" as,

#0000

#0000

    ;   often, the code makes assumptions about these addresses. For example, when it checks if the

#0000

#0000

    ;   most-significant byte of a pointer if #dc or #fd to know we are out of bounds of a map. By

#0000

#0000

    ;   making the map label "Ldd00_map", it is at least clear that checking for "#dc" is to see if the

#0000

#0000

    ;   pointer is lower than #dd00, which is the beginning of the map.

#0000

#0000

    ;

#0000

#0000

    ; - There is some unreachable code (see label Lae29) in the code base, that contains code that is

#0000

#0000

    ;   probably left-over code.

#0000

#0000

    ;

#0000

#0000

    ; - There are also two gaps in the zone of RAM designated for variables. So, probably some

#0000

#0000

    ;   variables were defined, but unused in the final version of the code (search for "unused bytes"

#0000

#0000

    ;   in this file).

#0000

#0000

    ;

#0000

#0000

    ; - The music system is very interesting for a 48K Spectrum model:

#0000

#0000

    ;     - Look at "Lc4a7_title_music_loop"

#0000

#0000

    ;     - Basically, when playing music, the game runs a constant loop that iterates over 3

#0000

#0000

    ;       oscillators that produce sound.

#0000

#0000

    ;     - These oscillators are just 3 loops in the code that make the speaker vibrate with some

#0000

#0000

    ;       fixed frequencies.

#0000

#0000

    ;     - The interrupt routine has a script that, using self-modifiable code, modifies the

#0000

#0000

    ;       oscillator parameters in the loop.

#0000

#0000

    ;     - So, basically, the loop acts as a sound chip, and the interrupt basically sets its

#0000

#0000

    ;       parameters, mimicking 3 channel sound.

#0000

#0000

    ;     - Since it's a dedicated loop, nothing can run in parallel with it. So, as soon as the player

#0000

#0000

    ;       presses any key, music stops.

#0000

#0000

    ;

#0000

#0000

    ; - SFX:

#0000

#0000

    ;     - The game reads from the addresses in the Spectrum ROM and uses them to produce sound. This

#0000

#0000

    ;       is probably just some random sound (as those values are not a wave, but assembler code),

#0000

#0000

    ;       but the programmers chose different parts of the ROM that produce slightly different

#0000

#0000

    ;       sounds when reproduced, which is pretty smart.

#0000

#0000

    ;

#0000

#0000

    ; - Game-play details, not fully documented in the instructions:

#0000

#0000

    ;     - Weapons all fly at the same altitude (10) regardless of the height of the robot.

#0000

#0000

    ;     - Electronics:

#0000

#0000

    ;         - increase the range of weapons by 1 tile (what the manual states being 3 miles).

#0000

#0000

    ;         - they also increase the distance robots can "see" an opponent from 10 to 12 tiles.

#0000

#0000

    ;     - Each player can have at most 24 robots.

#0000

#0000

    ;     - There can only be 5 bullets at a time in the whole game:

#0000

#0000

    ;         - one bullet for the player controlled robot

#0000

#0000

    ;         - two bullets fired by friendly robots

#0000

#0000

    ;         - two bullets fired by enemy robots

#0000

#0000

    ;     - How much damage weapons deal is quite curious:

#0000

#0000

    ;         - The game calculates (60 - (robot height + ground height))/4 as the "base damage".

#0000

#0000

    ;         - Then cannon deals 2x the base damage, missiles 3x, and phasers 4x. (the Spanish

#0000

#0000

    ;           instruction manual is wrong here, stating that missiles do the same damage as cannon,

#0000

#0000

    ;           English is correct).

#0000

#0000

    ;         - So, robots that are on high ground receive less damage! Stand on a mountain to make a

#0000

#0000

    ;           robot more resistant!

#0000

#0000

    ;     - Since a robot can have at most 3 weapons, we have (see the

#0000

#0000

    ;       Ld7b4_piece_heights data below):

#0000

#0000

    ;         - The maximum height of a robot is: 11 + 6 + 7 + 7 + 7 = 38 (bipod, missiles, phase,

#0000

#0000

    ;           nuclear, electronics). This is the most resistant robot!

#0000

#0000

    ;         - The minimum height of a robot is: 7 + 6 = 13 (tracks, cannon). This is the weakest

#0000

#0000

    ;           robot!

#0000

#0000

    ;     - So, for example: phasers against the weakest robot (at ground level) deal: ((60 - 13)/4)*4

#0000

#0000

    ;       = 44 damage.

#0000

#0000

    ;     - The robot/enemy AI is extremely simple:

#0000

#0000

    ;         - see "Lb154_robot_ai_update" for the code that implements the AI of the robots,

#0000

#0000

    ;           including their limited "path-finding", and targetting.

#0000

#0000

    ;         - see "Lb7f4_update_enemy_ai" for the code that implements the strategy of the enemy

#0000

#0000

    ;           player.

#0000

#0000

    ;

#0000

#0000

    ; - Terminology:

#0000

#0000

    ;     - I often use the abbreviation "ptr." for "pointer".

#0000

#0000

    ;     - I often use the term "one-hot" (vector/byte). This is a way to represent numbers, where

#0000

#0000

    ;       only one bit of the byte is set to 1, and the others are zero. The number encoded is the

#0000

#0000

    ;       index of the bit that is set to 1. For example:

#0000

#0000

    ;         - 1 encoded as a one-hot vector is: 00000001

#0000

#0000

    ;         - 2 encoded as a one-hot vector is: 00000010

#0000

#0000

    ;         - 3 encoded as a one-hot vector is: 00000100

#0000

#0000

    ;         - 4 encoded as a one-hot vector is: 00001000

#0000

#0000

    ;         - etc.

#0000

#0000

    ;

#0000

#0000

    ; --------------------------------

#0000

#0000

#0000

#0000

#0000

#0000

    ; --------------------------------

#0000

#0000

    ; BIOS Functions and constants:

#0000

#0000

    ; - Information obtained from:

#0000

#0000

    ;   https://worldofspectrum.net/pub/sinclair/books/s/SpectrumMachineCodeReferenceGuideThe.pdf

#0000

#0000

    L0205_BIOS_KEYCODE_TABLE: equ #0205

#0000

#0000

    L028e_BIOS_POLL_KEYBOARD: equ #028e  ; Polls keyboard and builds up key code in DE

#0000

#0000

    L0556_BIOS_READ_FROM_TAPE: equ #0556  ; Load if carry set, load tape header if A=0 (nz=data).

#0000

#0000

                                          ; IX=address, DE=byte count

#0000

#0000

    L0562_BIOS_READ_FROM_TAPE_SKIP_TESTS: equ #0562

#0000

#0000

    L04c2_BIOS_CASSETTE_SAVE: equ #04c2

#0000

#0000

    L04d0_BIOS_CASSETTE_SAVE_SKIP_TESTS: equ #04d0

#0000

#0000

#0000

#0000

    L4000_VIDEOMEM_PATTERNS: equ #4000

#0000

#0000

    L5800_VIDEOMEM_ATTRIBUTES: equ #5800

#0000

#0000

#0000

#0000

    ULA_PORT: equ #fe

#0000

#0000

    KEMPSTON_JOYSTICK_PORT: equ 31

#0000

#0000

    INTERFACE2_JOYSTICK_PORT_MSB: equ #ef

#0000

#0000

#0000

#0000

    COLOR_BRIGHT: equ #40

#0000

#0000

    COLOR_BLACK: equ 0

#0000

#0000

    COLOR_BLUE: equ 1

#0000

#0000

    COLOR_RED: equ 2

#0000

#0000

    COLOR_PINK: equ 3

#0000

#0000

    COLOR_GREEN: equ 4

#0000

#0000

    COLOR_CYAN: equ 5

#0000

#0000

    COLOR_YELLOW: equ 6

#0000

#0000

    COLOR_WHITE: equ 7

#0000

#0000

    PAPER_COLOR_MULTIPLIER: equ 8

#0000

#0000

#0000

#0000

#0000

#0000

    ; --------------------------------

#0000

#0000

    ; Commands recognized by Ld42d_execute_ui_script:

#0000

#0000

    CMD_END: equ 0

#0000

#0000

    CMD_SET_POSITION: equ 1

#0000

#0000

    CMD_SET_ATTRIBUTE: equ 2

#0000

#0000

    CMD_NEXT_LINE: equ 3

#0000

#0000

    CMD_SET_SCALE: equ 4

#0000

#0000

#0000

#0000

#0000

#0000

    ; --------------------------------

#0000

#0000

    INPUT_KEYBOARD: equ 1

#0000

#0000

    INPUT_KEMPSTON: equ 2

#0000

#0000

    INPUT_INTERFACE2: equ 3

#0000

#0000

#0000

#0000

#0000

#0000

    ; --------------------------------

#0000

#0000

    ; Game constants:

#0000

#0000

    INITIAL_PLAYER_RESOURCES: equ 20

#0000

#0000

    MAX_ROBOTS_PER_PLAYER: equ 24

#0000

#0000

    MAX_BULLETS: equ 5

#0000

#0000

    N_WARBASES: equ 4

#0000

#0000

    N_FACTORIES: equ 24

#0000

#0000

    BUILDING_CAPTURE_TIME: equ 144

#0000

#0000

    MIN_INTERRUPTS_PER_GAME_CYCLE: equ 10  ; game maximum speed is 5 frames per second.

#0000

#0000

#0000

#0000

    MAX_PLAYER_ALTITUDE: equ 48

#0000

#0000

    MIN_PLAYER_X: equ 14

#0000

#0000

    MAX_PLAYER_X: equ 501

#0000

#0000

#0000

#0000

    MAP_LENGTH: equ 512  ; x coordinate

#0000

#0000

    MAP_WIDTH: equ 16  ; y coordinate

#0000

#0000

#0000

#0000

    ROBOT_ORDERS_STOP_AND_DEFEND: equ 0

#0000

#0000

    ROBOT_ORDERS_ADVANCE: equ 1

#0000

#0000

    ROBOT_ORDERS_RETREAT: equ 2

#0000

#0000

    ROBOT_ORDERS_DESTROY_ENEMY_ROBOTS: equ 3

#0000

#0000

    ROBOT_ORDERS_DESTROY_ENEMY_FACTORIES: equ 4

#0000

#0000

    ROBOT_ORDERS_DESTROY_ENEMY_WARBASES: equ 5

#0000

#0000

    ROBOT_ORDERS_CAPTURE_NEUTRAL_FACTORIES: equ 6

#0000

#0000

    ROBOT_ORDERS_CAPTURE_ENEMY_FACTORIES: equ 7

#0000

#0000

    ROBOT_ORDERS_CAPTURE_ENEMY_WARBASES: equ 8

#0000

#0000

#0000

#0000

    ROBOT_CONTROL_AUTO: equ 0

#0000

#0000

    ROBOT_CONTROL_PLAYER_LANDED: equ 1

#0000

#0000

    ROBOT_CONTROL_DIRECT_CONTROL: equ 2

#0000

#0000

    ROBOT_CONTROL_ENEMY_AI: equ 128

#0000

#0000

#0000

#0000

    WEAPON_RANGE_DEFAULT: equ 5

#0000

#0000

    WEAPON_RANGE_MISSILES: equ 7

#0000

#0000

#0000

#0000

#0000

#0000

    ; --------------------------------

#0000

#0000

    ; Game structs:

#0000

#0000

    ROBOT_STRUCT_SIZE: equ 16

#0000

#0000

    ROBOT_STRUCT_MAP_PTR: equ 0  ; 2 bytes (the first byte set to 0 when there is no robot in this

#0000

#0000

                                 ; struct).

#0000

#0000

    ROBOT_STRUCT_X: equ 2  ; 2 bytes

#0000

#0000

    ROBOT_STRUCT_Y: equ 4

#0000

#0000

    ROBOT_STRUCT_DESIRED_MOVE_DIRECTION: equ 5

#0000

#0000

    ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING: equ 6

#0000

#0000

    ROBOT_STRUCT_PIECES: equ 7

#0000

#0000

    ROBOT_STRUCT_DIRECTION: equ 8  ; one-hot representation: #01, #02, #04, #08

#0000

#0000

    ROBOT_STRUCT_HEIGHT: equ 9

#0000

#0000

    ROBOT_STRUCT_CONTROL: equ 10

#0000

#0000

    ROBOT_STRUCT_ORDERS: equ 11

#0000

#0000

    ROBOT_STRUCT_STRENGTH: equ 12

#0000

#0000

    ROBOT_STRUCT_ALTITUDE: equ 13

#0000

#0000

    ROBOT_STRUCT_ORDERS_ARGUMENT: equ 14  ; This can be # of miles, target robot index, etc.

#0000

#0000

    ROBOT_STRICT_CYCLES_TO_NEXT_UPDATE: equ 15

#0000

#0000

#0000

#0000

#0000

#0000

    BULLET_STRUCT_SIZE: equ 9

#0000

#0000

    BULLET_STRUCT_MAP_PTR: equ 0  ; 2 bytes (the first byte set to 0 when there is no bullet in this

#0000

#0000

                                  ; struct).

#0000

#0000

    BULLET_STRUCT_X: equ 2  ; 2 bytes

#0000

#0000

    BULLET_STRUCT_Y: equ 4

#0000

#0000

    BULLET_STRUCT_DIRECTION: equ 5

#0000

#0000

    BULLET_STRUCT_RANGE: equ 6

#0000

#0000

    BULLET_STRUCT_TYPE: equ 7  ; 1: cannon, 2: missiles, 3: phasers

#0000

#0000

    BULLET_STRUCT_ALTITUDE: equ 8

#0000

#0000

#0000

#0000

#0000

#0000

    BUILDING_STRUCT_SIZE: equ 5

#0000

#0000

    BUILDING_STRUCT_X: equ 0  ; 2 bytes

#0000

#0000

    BUILDING_STRUCT_Y: equ 2

#0000

#0000

    BUILDING_STRUCT_TYPE: equ 3  ; contains type + owner (owner in the most-significant bits: bit 6

#0000

#0000

                                 ; player 1, bit 5 player 2). bit 7 indicates building is destroyed.

#0000

#0000

    BUILDING_STRUCT_TIMER: equ 4  ; this counts the time the building is occupied by a robot

#0000

#0000

#0000

#0000

#0000

#0000

    BUILDING_DECORATION_STRUCT_SIZE: equ 3

#0000

#0000

    BUILDING_DECORATION_STRUCT_MAP_PTR: equ 0

#0000

#0000

    BUILDING_DECORATION_STRUCT_TYPE: equ 2

#0000

#0000

#0000

#0000

#0000

#0000

    ; --------------------------------

#0000

#0000

    ; RAM variables/buffers in the low region of RAM:

#0000

#0000

    ; The first 3200 bytes (starting at #5b00) are used as a double buffer, to render

#0000

#0000

    ; the screen there, before it is copied over to the video memory. 3200 bytes, as

#0000

#0000

    ; the game area is 160x160 pixels wide. So, 160/8 = 20 bytes per line, and 20*160 = 3200.

#0000

#0000

    L5b00: equ #5b00

#0000

#0000

    L5b00_double_buffer: equ #5b00

#0000

#0000

#0000

#0000

#0000

#0000

    ; --------------------------------

#0000

#0000

    ; Game graphic data"

#0000

#0000

        org #6780

#6780

#0000

#6780

15850

        include "netherearth-annotated-data.asm"

#a56a

#3dea

150

        ds #a600 - $, 0  ; 150 bytes of empty space until the game code starts.

#a600

#3e80

#a600

#3e80

#a600

#3e80

    ; --------------------------------

#a600

#3e80

    ; Game entry point

#a600

#3e80

    La600_start:

#a600

#3e80

        ; Set up the interrupts:

#a600

#3e80

1

5

    f3

        di

#a601

#3e81

3

11

    31 00 00

            ld sp, 0

#a604

#3e84

3

11

    21 00 fe

            ld hl, Lfe00_interrupt_vector_table

#a607

#3e87

3

11

    01 fd 00

            ld bc, #00fd

#a60a

#3e8a

            ; Write #fd to the interrupt vector table 257 times

#a60a

#3e8a

    La60a_interrupt_vector_table_init_loop:

#a60a

#3e8a

1

8

    71

            ld (hl), c

#a60b

#3e8b

1

7

    23

            inc hl

#a60c

#3e8c

2

14/9

    10 fc

            djnz La60a_interrupt_vector_table_init_loop

#a60e

#3e8e

1

8

    71

            ld (hl), c

#a60f

#3e8f

2

8

    3e c3

            ld a, #c3  ; jp opcode

#a611

#3e91

3

14

    32 fd fd

            ld (Lfdfd_interrupt_jp), a

#a614

#3e94

3

11

    21 9c d5

            ld hl, Ld59c_empty_interrupt

#a617

#3e97

3

17

    22 fe fd

            ld (Lfdfe_interrupt_pointer), hl  ; sets the interrupt routine

#a61a

#3e9a

2

8

    3e fe

            ld a, #fe

#a61c

#3e9c

2

11

    ed 47

            ld i, a  ; sets the interrupt vector tp #fe00

#a61e

#3e9e

2

10

    ed 5e

            im 2

#a620

#3ea0

1

5

    fb

        ei

#a621

#3ea1

#a621

#3ea1

        ; Initialize the random number generator:

#a621

#3ea1

3

11

    21 39 30

        ld hl, 12345  ; random seed

#a624

#3ea4

3

17

    22 00 fd

        ld (Lfd00_random_seed), hl

#a627

#3ea7

3

17

    22 02 fd

        ld (Lfd00_random_seed + 2), hl

#a62a

#3eaa

3

18

    cd 00 c1

        call Lc100_title_screen

#a62d

#3ead

2

13/8

    20 5f

        jr nz, La68e_game_loop_start  ; Start from a saved game

#a62f

#3eaf

#a62f

#3eaf

        ; Start new game from scratch:

#a62f

#3eaf

        ; Clear memory buffers:

#a62f

#3eaf

3

11

    21 00 da

        ld hl, Lda00_player1_robots

#a632

#3eb2

3

11

    11 01 da

        ld de, Lda00_player1_robots + 1

#a635

#3eb5

3

11

    01 ff 02

        ld bc, 2 * MAX_ROBOTS_PER_PLAYER * ROBOT_STRUCT_SIZE - 1

#a638

#3eb8

2

11

    36 00

        ld (hl), 0

#a63a

#3eba

2

23/18

    ed b0

        ldir

#a63c

#3ebc

3

11

    21 04 fd

        ld hl, Lfd04_script_video_pattern_ptr

#a63f

#3ebf

3

11

    11 05 fd

        ld de, Lfd04_script_video_pattern_ptr + 1

#a642

#3ec2

3

11

    01 f8 00

        ld bc, 248

#a645

#3ec5

2

11

    36 00

        ld (hl), 0

#a647

#3ec7

2

23/18

    ed b0

        ldir  ; This clears a whole set of in-game variables starting at Lfd04_script_video_pattern_ptr

#a649

#3ec9

3

11

    21 01 ff

        ld hl, Lff01_building_decorations

#a64c

#3ecc

3

11

    11 02 ff

        ld de, Lff01_building_decorations + 1

#a64f

#3ecf

3

11

    01 c8 00

        ld bc, 200  ; Potential optimization: change to 167 since only 168 bytes need to be cleared

#a652

#3ed2

                    ; here.

#a652

#3ed2

2

11

    36 00

        ld (hl), 0

#a654

#3ed4

2

23/18

    ed b0

        ldir

#a656

#3ed6

3

11

    21 d3 d7

        ld hl, Ld7d3_bullets

#a659

#3ed9

3

11

    11 d4 d7

        ld de, Ld7d3_bullets + 1

#a65c

#3edc

3

11

    01 2c 00

        ld bc, MAX_BULLETS * BULLET_STRUCT_SIZE - 1

#a65f

#3edf

2

11

    36 00

        ld (hl), 0

#a661

#3ee1

2

23/18

    ed b0

        ldir

#a663

#3ee3

#a663

#3ee3

        ; Initialize variables:

#a663

#3ee3

3

11

    21 00 dd

        ld hl, Ldd00_map

#a666

#3ee6

3

17

    22 06 fd

        ld (Lfd06_scroll_ptr), hl

#a669

#3ee9

3

11

    21 00 00

        ld hl, 0

#a66c

#3eec

3

17

    22 0a fd

        ld (Lfd0a_scroll_x), hl

#a66f

#3eef

3

11

    21 11 00

        ld hl, 17

#a672

#3ef2

3

17

    22 0e fd

        ld (Lfd0e_player_x), hl  ; set player start x

#a675

#3ef5

2

8

    3e 0a

        ld a, 10

#a677

#3ef7

3

14

    32 0d fd

        ld (Lfd0d_player_y), a  ; set player start y

#a67a

#3efa

1

5

    af

        xor a

#a67b

#3efb

3

14

    32 10 fd

        ld (Lfd10_player_altitude), a  ; set player start altitude

#a67e

#3efe

2

8

    3e 03

        ld a, 3

#a680

#3f00

3

14

    32 30 fd

        ld (Lfd30_player_elevate_timer), a  ; make the player float a bit right at game start

#a683

#3f03

2

8

    3e 14

        ld a, INITIAL_PLAYER_RESOURCES

#a685

#3f05

3

14

    32 22 fd

        ld (Lfd22_player1_resource_counts), a

#a688

#3f08

3

14

    32 4a fd

        ld (Lfd4a_player2_resource_counts), a

#a68b

#3f0b

3

18

    cd 6f bc

        call Lbc6f_initialize_map

#a68e

#3f0e

#a68e

#3f0e

#a68e

#3f0e

    ; --------------------------------

#a68e

#3f0e

    ; This is the main game loop:

#a68e

#3f0e

    La68e_game_loop_start:

#a68e

#3f0e

3

18

    cd d7 cf

        call Lcfd7_draw_blank_map_in_buffer

#a691

#3f11

3

18

    cd ca d0

        call Ld0ca_draw_in_game_screen_and_hud

#a694

#3f14

3

11

    21 66 d5

        ld hl, Ld566_interrupt

#a697

#3f17

3

17

    22 fe fd

        ld (Lfdfe_interrupt_pointer), hl

#a69a

#3f1a

    La69a_game_loop:

#a69a

#3f1a

3

18

    cd 7c d3

        call Ld37c_read_keyboard_joystick_input

#a69d

#3f1d

3

18

    cd 11 af

        call Laf11_player_ship_keyboard_control

#a6a0

#3f20

3

18

    cd ca b0

        call Lb0ca_update_robots_bullets_and_ai

#a6a3

#3f23

3

18

    cd bd cc

        call Lccbd_redraw_game_area

#a6a6

#3f26

3

18

    cd 62 ad

        call Lad62_increase_time

#a6a9

#3f29

3

18

    cd a0 cc

        call Lcca0_compute_player_map_ptr

#a6ac

#3f2c

2

14

    cb 76

        bit 6, (hl)

#a6ae

#3f2e

2

13/8

    28 5d

        jr z, La70d_game_loop_continue

#a6b0

#3f30

3

18

    cd d8 cd

        call Lcdd8_get_robot_at_ptr

#a6b3

#3f33

2

13/8

    20 13

        jr nz, La6c8_not_landed_on_a_robot

#a6b5

#3f35

1

5

    78

        ld a, b

#a6b6

#3f36

2

8

    fe 19

        cp MAX_ROBOTS_PER_PLAYER + 1  ; if it's not one of the player's robots, ignore

#a6b8

#3f38

2

13/8

    38 53

        jr c, La70d_game_loop_continue

#a6ba

#3f3a

3

14

    3a 10 fd

        ld a, (Lfd10_player_altitude)

#a6bd

#3f3d

3

21

    fd 96 09

        sub (iy + ROBOT_STRUCT_HEIGHT)

#a6c0

#3f40

3

21

    fd 96 0d

        sub (iy + ROBOT_STRUCT_ALTITUDE)

#a6c3

#3f43

3

18/11

    cc 20 a7

        call z, La720_land_on_robot  ; if we are right on top of the robot, control it!

#a6c6

#3f46

2

13

    18 45

        jr La70d_game_loop_continue

#a6c8

#3f48

#a6c8

#3f48

    La6c8_not_landed_on_a_robot:

#a6c8

#3f48

3

18

    cd f5 cd

        call Lcdf5_find_building_decoration_with_ptr

#a6cb

#3f4b

2

13/8

    20 40

        jr nz, La70d_game_loop_continue  ; player is not on top of any ownable building

#a6cd

#3f4d

3

21

    fd 7e 02

        ld a, (iy + BUILDING_DECORATION_STRUCT_TYPE)

#a6d0

#3f50

1

5

    b7

        or a

#a6d1

#3f51

2

13/8

    20 3a

        jr nz, La70d_game_loop_continue  ; player is not on top of an "H" decoration

#a6d3

#3f53

3

14

    3a 10 fd

        ld a, (Lfd10_player_altitude)

#a6d6

#3f56

2

8

    fe 0f

        cp 15

#a6d8

#3f58

2

13/8

    20 33

        jr nz, La70d_game_loop_continue  ; player is not at the right height

#a6da

#3f5a

3

21

    fd 6e 00

        ld l, (iy + BUILDING_DECORATION_STRUCT_MAP_PTR)

#a6dd

#3f5d

3

21

    fd 7e 01

        ld a, (iy + BUILDING_DECORATION_STRUCT_MAP_PTR + 1)

#a6e0

#3f60

2

8

    c6 08

        add a, 8

#a6e2

#3f62

1

5

    67

        ld h, a

#a6e3

#3f63

        ; check for bit 6 in a 2x2 rectangle around the building map ptr, this is to

#a6e3

#3f63

        ; make sure the building is still there and not destroyed:

#a6e3

#3f63

1

8

    7e

        ld a, (hl)

#a6e4

#3f64

1

5

    24

        inc h

#a6e5

#3f65

1

5

    24

        inc h

#a6e6

#3f66

1

8

    b6

        or (hl)

#a6e7

#3f67

1

7

    2b

        dec hl

#a6e8

#3f68

1

8

    b6

        or (hl)

#a6e9

#3f69

1

7

    23

        inc hl

#a6ea

#3f6a

1

7

    23

        inc hl

#a6eb

#3f6b

1

8

    b6

        or (hl)

#a6ec

#3f6c

2

8

    e6 40

        and #40

#a6ee

#3f6e

2

13/8

    20 1d

        jr nz, La70d_game_loop_continue  ; not landed on a warbase

#a6f0

#3f70

3

18

    cd 49 c8

        call Lc849_robot_construction_if_possible

#a6f3

#3f73

        ; Reset state of newly created robot:

#a6f3

#3f73

4

21

    fd 36 05 04

        ld (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION), 4  ; more down by default

#a6f7

#3f77

4

21

    fd 36 06 05

        ld (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), 5  ; walk 5 steps after exiting the

#a6fb

#3f7b

                                                                   ; base, and stop

#a6fb

#3f7b

4

21

    fd 36 0b 00

        ld (iy + ROBOT_STRUCT_ORDERS), ROBOT_ORDERS_STOP_AND_DEFEND

#a6ff

#3f7f

4

21

    fd 36 0c 64

        ld (iy + ROBOT_STRUCT_STRENGTH), 100

#a703

#3f83

4

21

    fd 36 0f 01

        ld (iy + ROBOT_STRICT_CYCLES_TO_NEXT_UPDATE), 1

#a707

#3f87

3

18

    cd 40 bb

        call Lbb40_count_robots

#a70a

#3f8a

3

18

    cd 93 d2

        call Ld293_update_stats_in_right_hud

#a70d

#3f8d

    La70d_game_loop_continue:

#a70d

#3f8d

3

14

    3a 0c fd

        ld a, (Lfd0c_keyboard_state)

#a710

#3f90

2

10

    cb 77

        bit 6, a  ; restart key

#a712

#3f92

3

11

    c2 00 a6

        jp nz, La600_start

#a715

#3f95

2

10

    cb 6f

        bit 5, a  ; save game key

#a717

#3f97

3

11

    ca 9a a6

        jp z, La69a_game_loop

#a71a

#3f9a

3

18

    cd 8d c2

        call Lc28d_save_game

#a71d

#3f9d

3

11

    c3 8e a6

        jp La68e_game_loop_start

#a720

#3fa0

#a720

#3fa0

#a720

#3fa0

    ; --------------------------------

#a720

#3fa0

    ; Player lands on a robot.

#a720

#3fa0

    ; Input:

#a720

#3fa0

    ; - iy: robot player landed on

#a720

#3fa0

    La720_land_on_robot:

#a720

#3fa0

2

17

    fd e5

        push iy

#a722

#3fa2

2

16

    dd e1

        pop ix

#a724

#3fa4

4

21

    dd 36 0a 01

        ld (ix + ROBOT_STRUCT_CONTROL), ROBOT_CONTROL_PLAYER_LANDED

#a728

#3fa8

2

8

    3e 04

        ld a, 4

#a72a

#3faa

3

14

    32 1f fd

        ld (Lfd1f_cursor_position), a

#a72d

#3fad

2

8

    3e 01

        ld a, 1

#a72f

#3faf

3

14

    32 39 fd

        ld (Lfd39_current_in_game_right_hud), a

#a732

#3fb2

    La732_land_on_robot_internal:

#a732

#3fb2

3

18

    cd f6 d2

        call Ld2f6_clear_in_game_right_hud

#a735

#3fb5

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#a738

#3fb8

        ; script start:

#a738

#3fb8

3

            db CMD_SET_POSITION, #04, #17

#a73b

#3fbb

2

            db CMD_SET_ATTRIBUTE, #4d

#a73d

#3fbd

8

            db "DIRECT  "

#a745

#3fc5

1

            db CMD_NEXT_LINE

#a746

#3fc6

8

            db " CONTROL"

#a74e

#3fce

1

            db CMD_NEXT_LINE

#a74f

#3fcf

1

            db CMD_NEXT_LINE

#a750

#3fd0

8

            db "GIVE    "

#a758

#3fd8

1

            db CMD_NEXT_LINE

#a759

#3fd9

8

            db "  ORDERS"

#a761

#3fe1

1

            db CMD_NEXT_LINE

#a762

#3fe2

1

            db CMD_NEXT_LINE

#a763

#3fe3

8

            db "COMBAT  "

#a76b

#3feb

1

            db CMD_NEXT_LINE

#a76c

#3fec

8

            db "    MODE"

#a774

#3ff4

1

            db CMD_NEXT_LINE

#a775

#3ff5

1

            db CMD_NEXT_LINE

#a776

#3ff6

8

            db "LEAVE   "

#a77e

#3ffe

1

            db CMD_NEXT_LINE

#a77f

#3fff

8

            db "   ROBOT"

#a787

#4007

3

            db CMD_SET_POSITION, #11, #17

#a78a

#400a

2

            db CMD_SET_ATTRIBUTE, #46

#a78c

#400c

8

            db "-ORDERS-"

#a794

#4014

1

            db CMD_END

#a795

#4015

        ; script end:

#a795

#4015

        ; Print the robot current orders in the hud:

#a795

#4015

3

21

    dd 46 0b

        ld b, (ix + ROBOT_STRUCT_ORDERS)

#a798

#4018

1

5

    04

        inc b

#a799

#4019

3

11

    21 2d a8

        ld hl, La848_possible_robot_order_names - 27

#a79c

#401c

3

11

    11 1b 00

        ld de, 27

#a79f

#401f

    La79f_get_orders_name_loop:

#a79f

#401f

1

12

    19

        add hl, de

#a7a0

#4020

2

14/9

    10 fd

        djnz La79f_get_orders_name_loop

#a7a2

#4022

        ; Copy the current orders to the script below, so we can draw it:

#a7a2

#4022

3

11

    11 b2 a7

        ld de, La7b2_current_orders_buffer

#a7a5

#4025

3

11

    01 1b 00

        ld bc, 27

#a7a8

#4028

2

23/18

    ed b0

        ldir

#a7aa

#402a

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#a7ad

#402d

        ; script start:

#a7ad

#402d

3

            db CMD_SET_POSITION, #12, #17

#a7b0

#4030

2

            db CMD_SET_ATTRIBUTE, #45

#a7b2

#4032

    La7b2_current_orders_buffer:

#a7b2

#4032

16

            db #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00

#a7c2

#4042

11

            db #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00

#a7cd

#404d

        ; script end:

#a7cd

#404d

3

21

    dd 7e 0b

        ld a, (ix + ROBOT_STRUCT_ORDERS)

#a7d0

#4050

1

5

    3d

        dec a

#a7d1

#4051

2

8

    fe 02

        cp 2

#a7d3

#4053

2

13/8

    30 0f

        jr nc, La7e4_no_miles

#a7d5

#4055

        ; If there orders are advance/retreat, display the # of miles:

#a7d5

#4055

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#a7d8

#4058

        ; script start:

#a7d8

#4058

3

            db CMD_SET_POSITION, #13, #19

#a7db

#405b

1

            db CMD_END

#a7dc

#405c

        ; script end:

#a7dc

#405c

3

21

    dd 7e 0e

        ld a, (ix + ROBOT_STRUCT_ORDERS_ARGUMENT)

#a7df

#405f

2

10

    cb 3f

        srl a

#a7e1

#4061

3

18

    cd e5 d3

        call Ld3e5_render_8bit_number

#a7e4

#4064

    La7e4_no_miles:

#a7e4

#4064

3

18

    cd 1d a8

        call La81d_draw_robot_strength

#a7e7

#4067

3

11

    21 37 58

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0037

#a7ea

#406a

2

8

    1e 05

        ld e, 5

#a7ec

#406c

3

14

    3a 1f fd

        ld a, (Lfd1f_cursor_position)

#a7ef

#406f

3

18

    cd d7 ac

        call Lacd7_right_hud_menu_control

#a7f2

#4072

3

14

    32 1f fd

        ld (Lfd1f_cursor_position), a

#a7f5

#4075

1

5

    3d

        dec a

#a7f6

#4076

3

11

    ca 3b a9

        jp z, La93b_direct_control

#a7f9

#4079

1

5

    3d

        dec a

#a7fa

#407a

3

11

    ca 71 a9

        jp z, La971_give_orders

#a7fd

#407d

1

5

    3d

        dec a

#a7fe

#407e

3

11

    ca 00 ac

        jp z, Lac00_combat_mode

#a801

#4081

2

8

    3e 78

        ld a, 120

#a803

#4083

3

18

    cd ac cc

        call Lccac_beep

#a806

#4086

1

5

    af

        xor a

#a807

#4087

3

21

    dd 77 06

        ld (ix + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), a

#a80a

#408a

3

21

    dd 77 0a

        ld (ix + ROBOT_STRUCT_CONTROL), a  ; robot controls itself again

#a80d

#408d

2

8

    3e 05

        ld a, 5

#a80f

#408f

3

14

    32 30 fd

        ld (Lfd30_player_elevate_timer), a  ; make the player float a bit after exiting a robot

#a812

#4092

    La812_exit_robot:

#a812

#4092

3

18

    cd f6 d2

        call Ld2f6_clear_in_game_right_hud  ; potential optimization: this line is not needed

#a815

#4095

1

5

    af

        xor a

#a816

#4096

3

14

    32 39 fd

        ld (Lfd39_current_in_game_right_hud), a

#a819

#4099

3

18

    cd e5 d1

        call Ld1e5_draw_in_game_right_hud  ; potential optimization: tail recursion

#a81c

#409c

1

11

    c9

        ret

#a81d

#409d

#a81d

#409d

#a81d

#409d

    ; --------------------------------

#a81d

#409d

    ; Draws the remaining strength (hit points) of a robot.

#a81d

#409d

    La81d_draw_robot_strength:

#a81d

#409d

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#a820

#40a0

        ; script start:

#a820

#40a0

3

            db CMD_SET_POSITION, #16, #17

#a823

#40a3

2

            db CMD_SET_ATTRIBUTE, #46

#a825

#40a5

8

            db "STRENGTH"

#a82d

#40ad

3

            db CMD_SET_POSITION, #17, #19

#a830

#40b0

2

            db CMD_SET_ATTRIBUTE, #47

#a832

#40b2

1

            db CMD_END

#a833

#40b3

        ; script end:

#a833

#40b3

3

21

    dd 7e 0c

        ld a, (ix + ROBOT_STRUCT_STRENGTH)

#a836

#40b6

1

5

    b7

        or a

#a837

#40b7

3

11

    f2 3b a8

        jp p, La83b_positive_strength

#a83a

#40ba

1

5

    af

        xor a

#a83b

#40bb

    La83b_positive_strength:

#a83b

#40bb

1

5

    6f

        ld l, a

#a83c

#40bc

2

8

    26 00

        ld h, 0

#a83e

#40be

2

8

    1e 20

        ld e, " "

#a840

#40c0

3

18

    cd 01 d4

        call Ld401_render_16bit_number_3digits

#a843

#40c3

2

8

    3e 25

        ld a, "%"

#a845

#40c5

3

11

    c3 27 d4

        jp Ld427_draw_character_saving_registers

#a848

#40c8

#a848

#40c8

#a848

#40c8

    ; --------------------------------

#a848

#40c8

    La848_possible_robot_order_names:

#a848

#40c8

8

        db "  STOP  "

#a850

#40d0

1

        db CMD_NEXT_LINE

#a851

#40d1

8

        db "  AND   "

#a859

#40d9

1

        db CMD_NEXT_LINE

#a85a

#40da

8

        db " DEFEND "

#a862

#40e2

1

        db CMD_END

#a863

#40e3

#a863

#40e3

8

        db "ADVANCE "

#a86b

#40eb

1

        db CMD_NEXT_LINE

#a86c

#40ec

8

        db "        "

#a874

#40f4

1

        db CMD_NEXT_LINE

#a875

#40f5

8

        db " MILES  "

#a87d

#40fd

1

        db CMD_END

#a87e

#40fe

#a87e

#40fe

8

        db "RETREAT "

#a886

#4106

1

        db CMD_NEXT_LINE

#a887

#4107

8

        db "        "

#a88f

#410f

1

        db CMD_NEXT_LINE

#a890

#4110

8

        db " MILES  "

#a898

#4118

1

        db CMD_END

#a899

#4119

#a899

#4119

8

        db "DESTROY "

#a8a1

#4121

1

        db CMD_NEXT_LINE

#a8a2

#4122

8

        db " ENEMY  "

#a8aa

#412a

1

        db CMD_NEXT_LINE

#a8ab

#412b

8

        db " ROBOTS "

#a8b3

#4133

1

        db CMD_END

#a8b4

#4134

#a8b4

#4134

8

        db "DESTROY "

#a8bc

#413c

1

        db CMD_NEXT_LINE

#a8bd

#413d

8

        db " ENEMY  "

#a8c5

#4145

1

        db CMD_NEXT_LINE

#a8c6

#4146

8

        db "FACTORYS"

#a8ce

#414e

1

        db CMD_END

#a8cf

#414f

#a8cf

#414f

8

        db "DESTROY "

#a8d7

#4157

1

        db CMD_NEXT_LINE

#a8d8

#4158

8

        db " ENEMY  "

#a8e0

#4160

1

        db CMD_NEXT_LINE

#a8e1

#4161

8

        db "WARBASES"

#a8e9

#4169

1

        db CMD_END

#a8ea

#416a

#a8ea

#416a

8

        db "CAPTURE "

#a8f2

#4172

1

        db CMD_NEXT_LINE

#a8f3

#4173

8

        db "NEUTRAL "

#a8fb

#417b

1

        db CMD_NEXT_LINE

#a8fc

#417c

8

        db "FACTORYS"

#a904

#4184

1

        db CMD_END

#a905

#4185

#a905

#4185

8

        db "CAPTURE "

#a90d

#418d

1

        db CMD_NEXT_LINE

#a90e

#418e

8

        db " ENEMY  "

#a916

#4196

1

        db CMD_NEXT_LINE

#a917

#4197

8

        db "FACTORYS"

#a91f

#419f

1

        db CMD_END

#a920

#41a0

#a920

#41a0

8

        db "CAPTURE "

#a928

#41a8

1

        db CMD_NEXT_LINE

#a929

#41a9

8

        db " ENEMY  "

#a931

#41b1

1

        db CMD_NEXT_LINE

#a932

#41b2

8

        db "WARBASES"

#a93a

#41ba

1

        db CMD_END

#a93b

#41bb

#a93b

#41bb

#a93b

#41bb

    ; --------------------------------

#a93b

#41bb

    ; Jumps to the direct-control interface, and goes back to the "land on robot" menu after that.

#a93b

#41bb

    La93b_direct_control:

#a93b

#41bb

3

18

    cd 41 a9

        call La941_direct_control_internal

#a93e

#41be

3

11

    c3 32 a7

        jp La732_land_on_robot_internal

#a941

#41c1

#a941

#41c1

#a941

#41c1

    ; --------------------------------

#a941

#41c1

    ; Direct control of a robot.

#a941

#41c1

    La941_direct_control_internal:

#a941

#41c1

4

21

    dd 36 0a 02

        ld (ix + ROBOT_STRUCT_CONTROL), ROBOT_CONTROL_DIRECT_CONTROL

#a945

#41c5

4

21

    dd 36 05 00

        ld (ix + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION), 0  ; stop the automatic movement of the robot

#a949

#41c9

3

18

    cd 57 ad

        call Lad57_wait_until_no_keys_pressed

#a94c

#41cc

    La94c_direct_control_loop:

#a94c

#41cc

3

18

    cd ca b0

        call Lb0ca_update_robots_bullets_and_ai

#a94f

#41cf

3

18

    cd bd cc

        call Lccbd_redraw_game_area

#a952

#41d2

3

18

    cd 48 b0

        call Lb048_update_radar

#a955

#41d5

3

18

    cd 62 ad

        call Lad62_increase_time

#a958

#41d8

3

18

    cd 1d a8

        call La81d_draw_robot_strength

#a95b

#41db

3

21

    dd 7e 01

        ld a, (ix + 1)

#a95e

#41de

1

5

    b7

        or a

#a95f

#41df

1

12/6

    c8

        ret z  ; If the robot is destroyed, exit.

#a960

#41e0

3

18

    cd 7c d3

        call Ld37c_read_keyboard_joystick_input

#a963

#41e3

2

8

    e6 10

        and 16  ; If we press "fire", exit

#a965

#41e5

2

13/8

    28 e5

        jr z, La94c_direct_control_loop

#a967

#41e7

4

21

    dd 36 0a 01

        ld (ix + ROBOT_STRUCT_CONTROL), ROBOT_CONTROL_PLAYER_LANDED

#a96b

#41eb

2

8

    3e 78

        ld a, 120

#a96d

#41ed

3

18

    cd ac cc

        call Lccac_beep

#a970

#41f0

1

11

    c9

        ret

#a971

#41f1

#a971

#41f1

#a971

#41f1

    ; --------------------------------

#a971

#41f1

    ; This function implements the menu to give new orders to a robot.

#a971

#41f1

    La971_give_orders:

#a971

#41f1

3

18

    cd f6 d2

        call Ld2f6_clear_in_game_right_hud

#a974

#41f4

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#a977

#41f7

        ; script start:

#a977

#41f7

3

            db CMD_SET_POSITION, #04, #18

#a97a

#41fa

2

            db CMD_SET_ATTRIBUTE, #47

#a97c

#41fc

6

            db "SELECT"

#a982

#4202

1

            db CMD_NEXT_LINE

#a983

#4203

6

            db "ORDERS"

#a989

#4209

2

            db CMD_SET_ATTRIBUTE, #4d

#a98b

#420b

3

            db CMD_SET_POSITION, #07, #17

#a98e

#420e

8

            db "STOP AND"

#a996

#4216

1

            db CMD_NEXT_LINE

#a997

#4217

8

            db "  DEFEND"

#a99f

#421f

1

            db CMD_NEXT_LINE

#a9a0

#4220

1

            db CMD_NEXT_LINE

#a9a1

#4221

8

            db "ADVANCE "

#a9a9

#4229

1

            db CMD_NEXT_LINE

#a9aa

#422a

8

            db "?? MILES"

#a9b2

#4232

1

            db CMD_NEXT_LINE

#a9b3

#4233

1

            db CMD_NEXT_LINE

#a9b4

#4234

8

            db "RETREAT "

#a9bc

#423c

1

            db CMD_NEXT_LINE

#a9bd

#423d

8

            db "?? MILES"

#a9c5

#4245

1

            db CMD_NEXT_LINE

#a9c6

#4246

1

            db CMD_NEXT_LINE

#a9c7

#4247

8

            db "SEARCH &"

#a9cf

#424f

1

            db CMD_NEXT_LINE

#a9d0

#4250

8

            db " DESTROY"

#a9d8

#4258

1

            db CMD_NEXT_LINE

#a9d9

#4259

1

            db CMD_NEXT_LINE

#a9da

#425a

8

            db "SEARCH &"

#a9e2

#4262

1

            db CMD_NEXT_LINE

#a9e3

#4263

8

            db " CAPTURE"

#a9eb

#426b

1

            db CMD_END

#a9ec

#426c

        ; script end:

#a9ec

#426c

3

18

    cd 1d a8

        call La81d_draw_robot_strength

#a9ef

#426f

3

11

    21 97 58

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0097  ; ptr to the start of the menu attributes

#a9f2

#4272

2

8

    1e 06

        ld e, 6  ; this menu has 5 options

#a9f4

#4274

2

8

    3e 01

        ld a, 1  ; we start in option 1

#a9f6

#4276

3

18

    cd d7 ac

        call Lacd7_right_hud_menu_control

#a9f9

#4279

1

12

    f5

        push af

#a9fa

#427a

3

18

    cd 57 ad

            call Lad57_wait_until_no_keys_pressed

#a9fd

#427d

1

11

    f1

        pop af

#a9fe

#427e

1

5

    3d

        dec a

#a9ff

#427f

2

13/8

    20 0b

        jr nz, Laa0c_no_stop_and_defend

#aa01

#4281

3

21

    dd 77 0b

        ld (ix + ROBOT_STRUCT_ORDERS), a  ; stop and defend

#aa04

#4284

2

8

    3e 78

        ld a, 120

#aa06

#4286

3

18

    cd ac cc

        call Lccac_beep

#aa09

#4289

3

11

    c3 32 a7

        jp La732_land_on_robot_internal

#aa0c

#428c

    Laa0c_no_stop_and_defend:

#aa0c

#428c

2

8

    fe 03

        cp 3

#aa0e

#428e

3

11

    d2 cf aa

        jp nc, Laacf_give_capture_or_destroy_orders

#aa11

#4291

        ; We have selected advance or retreat:

#aa11

#4291

3

21

    dd 77 0b

        ld (ix + ROBOT_STRUCT_ORDERS), a

#aa14

#4294

1

12

    f5

        push af

#aa15

#4295

3

18

    cd f6 d2

            call Ld2f6_clear_in_game_right_hud

#aa18

#4298

1

11

    f1

        pop af

#aa19

#4299

1

5

    3d

        dec a

#aa1a

#429a

2

13/8

    20 13

        jr nz, Laa2f_retreat

#aa1c

#429c

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#aa1f

#429f

        ; Script start:

#aa1f

#429f

3

            db CMD_SET_POSITION, #05, #17

#aa22

#42a2

2

            db CMD_SET_ATTRIBUTE, #4f

#aa24

#42a4

8

            db "ADVANCE "

#aa2c

#42ac

1

            db CMD_END

#aa2d

#42ad

        ; Script end:

#aa2d

#42ad

2

13

    18 11

        jr Laa40_advance_or_retreat_drawn

#aa2f

#42af

    Laa2f_retreat:

#aa2f

#42af

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#aa32

#42b2

        ; Script start:

#aa32

#42b2

3

            db CMD_SET_POSITION, #05, #17

#aa35

#42b5

2

            db CMD_SET_ATTRIBUTE, #4f

#aa37

#42b7

8

            db "RETREAT "

#aa3f

#42bf

1

            db CMD_END

#aa40

#42c0

        ; Script end:

#aa40

#42c0

    Laa40_advance_or_retreat_drawn:

#aa40

#42c0

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#aa43

#42c3

        ; Script start:

#aa43

#42c3

1

            db CMD_NEXT_LINE

#aa44

#42c4

8

            db "?? MILES"

#aa4c

#42cc

3

            db CMD_SET_POSITION, #09, #17

#aa4f

#42cf

2

            db CMD_SET_ATTRIBUTE, #45

#aa51

#42d1

7

            db " SELECT"

#aa58

#42d8

1

            db CMD_NEXT_LINE

#aa59

#42d9

8

            db "DISTANCE"

#aa61

#42e1

3

            db CMD_SET_POSITION, #0d, #18

#aa64

#42e4

2

            db CMD_SET_ATTRIBUTE, #46

#aa66

#42e6

7

            db "0 MILES"

#aa6d

#42ed

1

            db CMD_END

#aa6e

#42ee

        ; Script end:

#aa6e

#42ee

2

8

    16 00

        ld d, 0  ; 0 miles to start

#aa70

#42f0

    Laa70_select_miles_loop:

#aa70

#42f0

1

12

    d5

        push de

#aa71

#42f1

3

18

    cd 1d a8

            call La81d_draw_robot_strength

#aa74

#42f4

3

18

    cd ca b0

            call Lb0ca_update_robots_bullets_and_ai

#aa77

#42f7

3

18

    cd bd cc

            call Lccbd_redraw_game_area

#aa7a

#42fa

3

18

    cd 48 b0

            call Lb048_update_radar

#aa7d

#42fd

3

18

    cd 62 ad

            call Lad62_increase_time

#aa80

#4300

1

11

    d1

        pop de

#aa81

#4301

3

21

    dd 7e 01

        ld a, (ix + 1)

#aa84

#4304

1

5

    b7

        or a  ; If robot is destroyed, exit.

#aa85

#4305

3

11

    ca 12 a8

        jp z, La812_exit_robot

#aa88

#4308

3

18

    cd 7c d3

        call Ld37c_read_keyboard_joystick_input

#aa8b

#430b

2

10

    cb 67

        bit 4, a

#aa8d

#430d

2

13/8

    20 29

        jr nz, Laab8_miles_selected  ; If fire pressed

#aa8f

#430f

1

5

    4a

        ld c, d

#aa90

#4310

1

5

    0f

        rrca

#aa91

#4311

1

5

    0f

        rrca

#aa92

#4312

2

8

    e6 03

        and 3

#aa94

#4314

2

13/8

    28 da

        jr z, Laa70_select_miles_loop  ; if we have not pressed up/down

#aa96

#4316

2

8

    e6 02

        and 2

#aa98

#4318

1

5

    47

        ld b, a

#aa99

#4319

1

5

    87

        add a, a

#aa9a

#431a

1

5

    87

        add a, a

#aa9b

#431b

1

5

    80

        add a, b

#aa9c

#431c

2

8

    d6 05

        sub 5  ; If we have pressed up, a = 5, otherwise, a = -5

#aa9e

#431e

1

5

    81

        add a, c  ; c was storing the # of miles

#aa9f

#431f

2

8

    fe 33

        cp 51

#aaa1

#4321

2

13/8

    30 cd

        jr nc, Laa70_select_miles_loop  ; Limit miles to 50

#aaa3

#4323

1

5

    57

        ld d, a  ; update the # miles

#aaa4

#4324

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#aaa7

#4327

        ; Script start:

#aaa7

#4327

3

            db CMD_SET_POSITION, #0d, #17

#aaaa

#432a

2

            db CMD_SET_ATTRIBUTE, #46

#aaac

#432c

1

            db CMD_END

#aaad

#432d

        ; Script end

#aaad

#432d

1

5

    7a

        ld a, d

#aaae

#432e

3

18

    cd e5 d3

        call Ld3e5_render_8bit_number

#aab1

#4331

2

8

    3e 14

        ld a, 20

#aab3

#4333

3

18

    cd ac cc

        call Lccac_beep

#aab6

#4336

2

13

    18 b8

        jr Laa70_select_miles_loop

#aab8

#4338

#aab8

#4338

    Laab8_miles_selected:

#aab8

#4338

1

5

    7a

        ld a, d

#aab9

#4339

1

5

    07

        rlca  ; multiply by 2: 1 mile == 2 coordinate units

#aaba

#433a

3

21

    dd 77 0e

        ld (ix + ROBOT_STRUCT_ORDERS_ARGUMENT), a  ; set the number of miles to advance

#aabd

#433d

1

5

    b7

        or a

#aabe

#433e

2

13/8

    20 04

        jr nz, Laac4  ; "advance/retreat 0 miles" is equivalent to stop and defend.

#aac0

#4340

4

21

    dd 36 0b 00

        ld (ix + ROBOT_STRUCT_ORDERS), ROBOT_ORDERS_STOP_AND_DEFEND

#aac4

#4344

    Laac4:

#aac4

#4344

2

8

    3e 78

        ld a, 120

#aac6

#4346

3

18

    cd ac cc

        call Lccac_beep

#aac9

#4349

3

18

    cd 57 ad

        call Lad57_wait_until_no_keys_pressed

#aacc

#434c

3

11

    c3 32 a7

        jp La732_land_on_robot_internal

#aacf

#434f

#aacf

#434f

    Laacf_give_capture_or_destroy_orders:

#aacf

#434f

3

11

    c2 4e ab

        jp nz, Lab4e_give_capture_orders

#aad2

#4352

        ; Destroy:

#aad2

#4352

3

18

    cd f6 d2

        call Ld2f6_clear_in_game_right_hud

#aad5

#4355

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#aad8

#4358

        ; Script start:

#aad8

#4358

3

            db CMD_SET_POSITION, #04, #17

#aadb

#435b

2

            db CMD_SET_ATTRIBUTE, #4f

#aadd

#435d

8

            db "SEARCH &"

#aae5

#4365

1

            db CMD_NEXT_LINE

#aae6

#4366

8

            db " DESTROY"

#aaee

#436e

3

            db CMD_SET_POSITION, #08, #18

#aaf1

#4371

2

            db CMD_SET_ATTRIBUTE, #45

#aaf3

#4373

6

            db "SELECT"

#aaf9

#4379

1

            db CMD_NEXT_LINE

#aafa

#437a

6

            db "TARGET"

#ab00

#4380

3

            db CMD_SET_POSITION, #0c, #17

#ab03

#4383

2

            db CMD_SET_ATTRIBUTE, #4d

#ab05

#4385

8

            db "ENEMY   "

#ab0d

#438d

1

            db CMD_NEXT_LINE

#ab0e

#438e

8

            db "  ROBOTS"

#ab16

#4396

1

            db CMD_NEXT_LINE

#ab17

#4397

1

            db CMD_NEXT_LINE

#ab18

#4398

8

            db "ENEMY   "

#ab20

#43a0

1

            db CMD_NEXT_LINE

#ab21

#43a1

8

            db "FACTORYS"

#ab29

#43a9

1

            db CMD_NEXT_LINE

#ab2a

#43aa

1

            db CMD_NEXT_LINE

#ab2b

#43ab

8

            db "ENEMY   "

#ab33

#43b3

1

            db CMD_NEXT_LINE

#ab34

#43b4

8

            db "WARBASES"

#ab3c

#43bc

1

            db CMD_END

#ab3d

#43bd

        ; Script end

#ab3d

#43bd

3

18

    cd 1d a8

        call La81d_draw_robot_strength

#ab40

#43c0

3

11

    21 37 59

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0137  ; ptr to the attributes of the first menu option

#ab43

#43c3

2

8

    3e 01

        ld a, 1  ; start at option 1

#ab45

#43c5

2

8

    1e 04

        ld e, 4  ; 3 options menu

#ab47

#43c7

3

18

    cd d7 ac

        call Lacd7_right_hud_menu_control

#ab4a

#43ca

2

8

    c6 02

        add a, ROBOT_ORDERS_DESTROY_ENEMY_ROBOTS - 1

#ab4c

#43cc

2

13

    18 7a

        jr Labc8_capture_or_destroy_order_selected

#ab4e

#43ce

#ab4e

#43ce

    Lab4e_give_capture_orders:

#ab4e

#43ce

3

18

    cd f6 d2

        call Ld2f6_clear_in_game_right_hud

#ab51

#43d1

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#ab54

#43d4

        ; Script start:

#ab54

#43d4

3

            db CMD_SET_POSITION, #04, #17

#ab57

#43d7

2

            db CMD_SET_ATTRIBUTE, #4f

#ab59

#43d9

8

            db "SEARCH &"

#ab61

#43e1

1

            db CMD_NEXT_LINE

#ab62

#43e2

8

            db " CAPTURE"

#ab6a

#43ea

3

            db CMD_SET_POSITION, #08, #18

#ab6d

#43ed

2

            db CMD_SET_ATTRIBUTE, #45

#ab6f

#43ef

6

            db "SELECT"

#ab75

#43f5

1

            db CMD_NEXT_LINE

#ab76

#43f6

6

            db "TARGET"

#ab7c

#43fc

3

            db CMD_SET_POSITION, #0c, #17

#ab7f

#43ff

2

            db CMD_SET_ATTRIBUTE, #4d

#ab81

#4401

8

            db "NEUTRAL "

#ab89

#4409

1

            db CMD_NEXT_LINE

#ab8a

#440a

8

            db "FACTORYS"

#ab92

#4412

1

            db CMD_NEXT_LINE

#ab93

#4413

1

            db CMD_NEXT_LINE

#ab94

#4414

8

            db "ENEMY   "

#ab9c

#441c

1

            db CMD_NEXT_LINE

#ab9d

#441d

8

            db "FACTORYS"

#aba5

#4425

1

            db CMD_NEXT_LINE

#aba6

#4426

1

            db CMD_NEXT_LINE

#aba7

#4427

8

            db "ENEMY   "

#abaf

#442f

1

            db CMD_NEXT_LINE

#abb0

#4430

8

            db "WARBASES"

#abb8

#4438

1

            db CMD_END

#abb9

#4439

        ; Script end:

#abb9

#4439

3

18

    cd 1d a8

        call La81d_draw_robot_strength

#abbc

#443c

3

11

    21 37 59

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0137  ; ptr to the attributes of the first menu option

#abbf

#443f

2

8

    3e 01

        ld a, 1  ; start at option 1

#abc1

#4441

2

8

    1e 04

        ld e, 4  ; 3 options menu

#abc3

#4443

3

18

    cd d7 ac

        call Lacd7_right_hud_menu_control

#abc6

#4446

2

8

    c6 05

        add a, ROBOT_ORDERS_CAPTURE_NEUTRAL_FACTORIES - 1

#abc8

#4448

#abc8

#4448

    Labc8_capture_or_destroy_order_selected:

#abc8

#4448

3

21

    dd 77 0b

        ld (ix + ROBOT_STRUCT_ORDERS), a

#abcb

#444b

2

8

    fe 04

        cp ROBOT_ORDERS_DESTROY_ENEMY_FACTORIES

#abcd

#444d

2

13/8

    38 0a

        jr c, Labd9_orders_executable

#abcf

#444f

2

8

    fe 06

        cp ROBOT_ORDERS_CAPTURE_NEUTRAL_FACTORIES

#abd1

#4451

2

13/8

    30 06

        jr nc, Labd9_orders_executable

#abd3

#4453

        ; Player has selected to destroy factories or warbases.

#abd3

#4453

        ; For that purpose, the robot must be equipped with a nuclear weapon.

#abd3

#4453

        ; Check if it does, and otherwise, just cancel the order:

#abd3

#4453

4

22

    dd cb 07 76

        bit 6, (ix + ROBOT_STRUCT_PIECES)

#abd7

#4457

2

13/8

    28 18

        jr z, Labf1_orders_not_executable

#abd9

#4459

    Labd9_orders_executable:

#abd9

#4459

3

21

    dd 6e 02

        ld l, (ix + ROBOT_STRUCT_X)

#abdc

#445c

3

21

    dd 66 03

        ld h, (ix + ROBOT_STRUCT_X + 1)

#abdf

#445f

1

12

    f5

        push af

#abe0

#4460

1

5

    af

            xor a

#abe1

#4461

3

14

    32 51 fd

            ld (Lfd51_current_robot_player_or_enemy), a

#abe4

#4464

1

11

    f1

        pop af

#abe5

#4465

4

21

    dd 36 0e ff

        ld (ix + ROBOT_STRUCT_ORDERS_ARGUMENT), #ff

#abe9

#4469

3

18

    cd 4d b3

        call Lb34d_find_capture_or_destroy_target

#abec

#446c

3

21

    dd 72 0e

        ld (ix + ROBOT_STRUCT_ORDERS_ARGUMENT), d

#abef

#446f

2

13/8

    20 04

        jr nz, Labf5_order_assignment_done

#abf1

#4471

    Labf1_orders_not_executable:

#abf1

#4471

4

21

    dd 36 0b 00

        ld (ix + ROBOT_STRUCT_ORDERS), ROBOT_ORDERS_STOP_AND_DEFEND

#abf5

#4475

    Labf5_order_assignment_done:

#abf5

#4475

2

8

    3e 78

        ld a, 120

#abf7

#4477

3

18

    cd ac cc

        call Lccac_beep

#abfa

#447a

3

18

    cd 57 ad

        call Lad57_wait_until_no_keys_pressed

#abfd

#447d

3

11

    c3 32 a7

        jp La732_land_on_robot_internal

#ac00

#4480

#ac00

#4480

#ac00

#4480

    ; --------------------------------

#ac00

#4480

    ; Combat mode menu loop.

#ac00

#4480

    Lac00_combat_mode:

#ac00

#4480

3

18

    cd f6 d2

        call Ld2f6_clear_in_game_right_hud

#ac03

#4483

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#ac06

#4486

        ; Start script:

#ac06

#4486

3

            db CMD_SET_POSITION, #04, #17

#ac09

#4489

2

            db CMD_SET_ATTRIBUTE, #4d

#ac0b

#448b

8

            db "NUCLEAR "

#ac13

#4493

1

            db CMD_NEXT_LINE

#ac14

#4494

8

            db "    BOMB"

#ac1c

#449c

1

            db CMD_NEXT_LINE

#ac1d

#449d

1

            db CMD_NEXT_LINE

#ac1e

#449e

8

            db "FIRE    "

#ac26

#44a6

1

            db CMD_NEXT_LINE

#ac27

#44a7

8

            db " PHASERS"

#ac2f

#44af

1

            db CMD_NEXT_LINE

#ac30

#44b0

1

            db CMD_NEXT_LINE

#ac31

#44b1

8

            db "FIRE    "

#ac39

#44b9

1

            db CMD_NEXT_LINE

#ac3a

#44ba

8

            db "MISSILES"

#ac42

#44c2

1

            db CMD_NEXT_LINE

#ac43

#44c3

1

            db CMD_NEXT_LINE

#ac44

#44c4

8

            db "FIRE    "

#ac4c

#44cc

1

            db CMD_NEXT_LINE

#ac4d

#44cd

8

            db "  CANNON"

#ac55

#44d5

1

            db CMD_NEXT_LINE

#ac56

#44d6

1

            db CMD_NEXT_LINE

#ac57

#44d7

8

            db "MOVE    "

#ac5f

#44df

1

            db CMD_NEXT_LINE

#ac60

#44e0

8

            db "   ROBOT"

#ac68

#44e8

1

            db CMD_NEXT_LINE

#ac69

#44e9

1

            db CMD_NEXT_LINE

#ac6a

#44ea

8

            db "STOP    "

#ac72

#44f2

1

            db CMD_NEXT_LINE

#ac73

#44f3

8

            db "  COMBAT"

#ac7b

#44fb

1

            db CMD_END

#ac7c

#44fc

        ; End script:

#ac7c

#44fc

3

18

    cd 1d a8

        call La81d_draw_robot_strength

#ac7f

#44ff

2

8

    3e 06

        ld a, 6  ; current option is the bottom

#ac81

#4501

    Lac81_combat_mode_loop:

#ac81

#4501

3

11

    21 37 58

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0037

#ac84

#4504

2

8

    1e 07

        ld e, 7  ; menu has 6 options

#ac86

#4506

3

18

    cd d7 ac

        call Lacd7_right_hud_menu_control

#ac89

#4509

2

8

    fe 06

        cp 6  ; stop combat

#ac8b

#450b

3

11

    ca 32 a7

        jp z, La732_land_on_robot_internal

#ac8e

#450e

1

12

    f5

        push af

#ac8f

#450f

2

8

    fe 05

            cp 5

#ac91

#4511

2

13/8

    20 06

            jr nz, Lac99_weapon_fire_selected

#ac93

#4513

3

18

    cd 41 a9

            call La941_direct_control_internal

#ac96

#4516

1

11

    f1

        pop af

#ac97

#4517

2

13

    18 e8

        jr Lac81_combat_mode_loop

#ac99

#4519

#ac99

#4519

    Lac99_weapon_fire_selected:

#ac99

#4519

1

5

    4f

            ld c, a

#ac9a

#451a

1

5

    47

            ld b, a

#ac9b

#451b

1

5

    04

            inc b

#ac9c

#451c

3

21

    dd 7e 07

            ld a, (ix + ROBOT_STRUCT_PIECES)

#ac9f

#451f

    Lac9f:

#ac9f

#451f

1

5

    07

            rlca

#aca0

#4520

2

14/9

    10 fd

            djnz Lac9f

#aca2

#4522

2

13/8

    30 2a

            jr nc, Lacce_selected_weapon_not_present

#aca4

#4524

1

11

    f1

        pop af

#aca5

#4525

2

8

    fe 01

        cp 1

#aca7

#4527

2

13/8

    20 0a

        jr nz, Lacb3_regular_weapon_fire

#aca9

#4529

        ; nuclear bomb selected:

#aca9

#4529

2

17

    dd e5

        push ix

#acab

#452b

2

16

    fd e1

        pop iy

#acad

#452d

3

18

    cd 9f b9

        call Lb99f_fire_nuclear_bomb

#acb0

#4530

3

11

    c3 12 a8

        jp La812_exit_robot

#acb3

#4533

#acb3

#4533

    Lacb3_regular_weapon_fire:

#acb3

#4533

        ; Weapon to fire is in "c"

#acb3

#4533

1

12

    f5

        push af

#acb4

#4534

            ; The first bullet record is used only for "combat mode". So, we only need to check if the

#acb4

#4534

            ; first bullet is available:

#acb4

#4534

4

16

    fd 21 d3 d7

            ld iy, Ld7d3_bullets

#acb8

#4538

3

21

    fd 7e 01

            ld a, (iy + 1)

#acbb

#453b

1

5

    b7

            or a  ; If there is already a weapon in use, we cannot fire

#acbc

#453c

2

13/8

    20 10

            jr nz, Lacce_selected_weapon_not_present

#acbe

#453e

2

8

    3e 05

            ld a, 5

#acc0

#4540

1

5

    91

            sub c

#acc1

#4541

3

18

    cd d6 b6

            call Lb6d6_weapon_fire

#acc4

#4544

3

18

    cd bd cc

            call Lccbd_redraw_game_area

#acc7

#4547

3

18

    cd 62 ad

            call Lad62_increase_time

#acca

#454a

1

11

    f1

        pop af

#accb

#454b

3

11

    c3 81 ac

        jp Lac81_combat_mode_loop

#acce

#454e

#acce

#454e

    Lacce_selected_weapon_not_present:

#acce

#454e

2

8

    3e fa

        ld a, 250

#acd0

#4550

3

18

    cd ac cc

        call Lccac_beep

#acd3

#4553

1

11

    f1

        pop af

#acd4

#4554

3

11

    c3 81 ac

        jp Lac81_combat_mode_loop

#acd7

#4557

#acd7

#4557

#acd7

#4557

    ; --------------------------------

#acd7

#4557

    ; Loop for moving around the options on a right-hand-side hud menu.

#acd7

#4557

    ; Input:

#acd7

#4557

    ; - a: cursor position.

#acd7

#4557

    ; - e: number of options in the menu

#acd7

#4557

    Lacd7_right_hud_menu_control:

#acd7

#4557

1

12

    f5

        push af

#acd8

#4558

3

18

    cd 57 ad

            call Lad57_wait_until_no_keys_pressed

#acdb

#455b

1

11

    f1

        pop af

#acdc

#455c

1

5

    57

        ld d, a

#acdd

#455d

2

8

    0e 4e

        ld c, COLOR_BRIGHT + COLOR_BLUE * PAPER_COLOR_MULTIPLIER + COLOR_YELLOW

#acdf

#455f

3

18

    cd 3c ad

        call Lad3c_set_attributes_for_menu_option

#ace2

#4562

    Lace2_right_hud_menu_control_loop:

#ace2

#4562

3

21

    dd 7e 01

        ld a, (ix + 1)  ; check if the robot is destroyed

#ace5

#4565

1

5

    b7

        or a

#ace6

#4566

2

13/8

    20 04

        jr nz, Lacec_robot_not_destroyed  ; if the robot is not destroyed, continue

#ace8

#4568

1

11

    e1

        pop hl  ; simulate a "ret"

#ace9

#4569

3

11

    c3 12 a8

        jp La812_exit_robot

#acec

#456c

    Lacec_robot_not_destroyed:

#acec

#456c

1

12

    e5

        push hl

#aced

#456d

3

18

    cd 7c d3

            call Ld37c_read_keyboard_joystick_input

#acf0

#4570

1

11

    e1

        pop hl

#acf1

#4571

1

5

    4a

        ld c, d  ; d still has the cursor position

#acf2

#4572

3

14

    3a 0c fd

        ld a, (Lfd0c_keyboard_state)

#acf5

#4575

2

10

    cb 67

        bit 4, a  ; is "fire" pressed

#acf7

#4577

2

13/8

    20 36

        jr nz, Lad2f_menu_option_selected

#acf9

#4579

1

5

    0f

        rrca

#acfa

#457a

2

8

    e6 06

        and 6

#acfc

#457c

2

13/8

    28 1c

        jr z, Lad1a_no_cursor_change  ; neither up nor down are pressed

#acfe

#457e

2

8

    e6 02

        and 2  ; if pressing down, a = 2, otherwise, a = 0

#ad00

#4580

1

5

    0d

        dec c  ; more cursor up

#ad01

#4581

1

5

    81

        add a, c  ; if we pressed down, a = option + 1, otherwise, option - 1

#ad02

#4582

2

13/8

    28 16

        jr z, Lad1a_no_cursor_change  ; if we pressed up and are at the top, no change

#ad04

#4584

1

5

    bb

        cp e

#ad05

#4585

2

13/8

    30 13

        jr nc, Lad1a_no_cursor_change  ; if we pressed down and we are at the bottom, no change

#ad07

#4587

1

12

    f5

        push af

#ad08

#4588

1

5

    7a

            ld a, d

#ad09

#4589

2

8

    0e 4d

            ld c, COLOR_BRIGHT + COLOR_BLUE * PAPER_COLOR_MULTIPLIER + COLOR_CYAN

#ad0b

#458b

3

18

    cd 3c ad

            call Lad3c_set_attributes_for_menu_option

#ad0e

#458e

1

11

    f1

        pop af

#ad0f

#458f

1

5

    57

        ld d, a

#ad10

#4590

2

8

    0e 4e

        ld c, COLOR_BRIGHT + COLOR_BLUE * PAPER_COLOR_MULTIPLIER + COLOR_YELLOW

#ad12

#4592

3

18

    cd 3c ad

        call Lad3c_set_attributes_for_menu_option

#ad15

#4595

2

8

    3e 14

        ld a, 20

#ad17

#4597

3

18

    cd ac cc

        call Lccac_beep

#ad1a

#459a

    Lad1a_no_cursor_change:

#ad1a

#459a

1

12

    d5

        push de

#ad1b

#459b

1

12

    e5

        push hl

#ad1c

#459c

            ; Advance on game tick:

#ad1c

#459c

3

18

    cd ca b0

            call Lb0ca_update_robots_bullets_and_ai

#ad1f

#459f

3

18

    cd bd cc

            call Lccbd_redraw_game_area

#ad22

#45a2

3

18

    cd 48 b0

            call Lb048_update_radar

#ad25

#45a5

3

18

    cd 62 ad

            call Lad62_increase_time

#ad28

#45a8

3

18

    cd 1d a8

            call La81d_draw_robot_strength

#ad2b

#45ab

1

11

    e1

        pop hl

#ad2c

#45ac

1

11

    d1

        pop de

#ad2d

#45ad

2

13

    18 b3

        jr Lace2_right_hud_menu_control_loop

#ad2f

#45af

    Lad2f_menu_option_selected:

#ad2f

#45af

1

5

    7a

        ld a, d  ; d still has the cursor position

#ad30

#45b0

2

8

    0e 4f

        ld c, COLOR_BRIGHT + COLOR_BLUE * PAPER_COLOR_MULTIPLIER + COLOR_WHITE

#ad32

#45b2

3

18

    cd 3c ad

        call Lad3c_set_attributes_for_menu_option

#ad35

#45b5

2

8

    3e 64

        ld a, 100

#ad37

#45b7

3

18

    cd ac cc

        call Lccac_beep

#ad3a

#45ba

1

5

    7a

        ld a, d  ; d still has the cursor position

#ad3b

#45bb

1

11

    c9

        ret

#ad3c

#45bc

#ad3c

#45bc

#ad3c

#45bc

    ; --------------------------------

#ad3c

#45bc

    ; Sets a 8x2 block in the attribute table to attribute "c". This is used to set the attributes of

#ad3c

#45bc

    ; menu options in the right-hand-side hud.

#ad3c

#45bc

    ; Input:

#ad3c

#45bc

    ; - c: attribute value to set

#ad3c

#45bc

    ; - a: which row to change attributes for (each row is 3 screen rows apart).

#ad3c

#45bc

    ; - hl: attribute address of the first row

#ad3c

#45bc

    Lad3c_set_attributes_for_menu_option:

#ad3c

#45bc

1

5

    47

        ld b, a

#ad3d

#45bd

1

12

    d5

        push de

#ad3e

#45be

1

12

    e5

        push hl

#ad3f

#45bf

3

11

    11 60 00

            ld de, 32 * 3

#ad42

#45c2

    Lad42:

#ad42

#45c2

1

12

    19

            add hl, de

#ad43

#45c3

2

14/9

    10 fd

            djnz Lad42

#ad45

#45c5

2

8

    06 08

            ld b, 8

#ad47

#45c7

3

18

    cd db cb

            call Lcbdb_set_attribute_loop  ; set 8 attribute positions to attribute "c"

#ad4a

#45ca

2

8

    3e 18

            ld a, 24

#ad4c

#45cc

3

18

    cd 51 d3

            call Ld351_add_hl_a  ; go one row down

#ad4f

#45cf

2

8

    06 08

            ld b, 8

#ad51

#45d1

3

18

    cd db cb

            call Lcbdb_set_attribute_loop  ; set 8 attribute positions to attribute "c"

#ad54

#45d4

1

11

    e1

        pop hl

#ad55

#45d5

1

11

    d1

        pop de

#ad56

#45d6

1

11

    c9

        ret

#ad57

#45d7

#ad57

#45d7

#ad57

#45d7

    ; --------------------------------

#ad57

#45d7

    ; Waits until the user is not pressing any key.

#ad57

#45d7

    Lad57_wait_until_no_keys_pressed:

#ad57

#45d7

1

12

    c5

        push bc

#ad58

#45d8

1

12

    e5

        push hl

#ad59

#45d9

    Lad59_wait_for_key_release_loop:

#ad59

#45d9

3

18

    cd 7c d3

            call Ld37c_read_keyboard_joystick_input

#ad5c

#45dc

1

5

    b7

            or a

#ad5d

#45dd

2

13/8

    20 fa

            jr nz, Lad59_wait_for_key_release_loop

#ad5f

#45df

1

11

    e1

        pop hl

#ad60

#45e0

1

11

    c1

        pop bc

#ad61

#45e1

1

11

    c9

        ret

#ad62

#45e2

#ad62

#45e2

#ad62

#45e2

    ; --------------------------------

#ad62

#45e2

    ; - increases time by 5 minutes, and checks if a whole day has passed, to give resources to the

#ad62

#45e2

    ;   players

#ad62

#45e2

    Lad62_increase_time:

#ad62

#45e2

3

18

    cd 58 d3

        call Ld358_random

#ad65

#45e5

3

11

    21 35 fd

        ld hl, Lfd35_minutes

#ad68

#45e8

1

8

    7e

        ld a, (hl)

#ad69

#45e9

2

8

    c6 05

        add a, 5  ; add 5 minutes

#ad6b

#45eb

1

8

    77

        ld (hl), a

#ad6c

#45ec

2

8

    fe 3c

        cp 60

#ad6e

#45ee

2

13/8

    20 15

        jr nz, Lad85_increase_time_done

#ad70

#45f0

2

11

    36 00

        ld (hl), 0  ; reset minutes

#ad72

#45f2

1

7

    23

        inc hl

#ad73

#45f3

1

12

    34

        inc (hl)  ; increase hour

#ad74

#45f4

1

8

    7e

        ld a, (hl)

#ad75

#45f5

2

8

    fe 18

        cp 24

#ad77

#45f7

2

13/8

    20 0c

        jr nz, Lad85_increase_time_done

#ad79

#45f9

2

11

    36 00

        ld (hl), 0  ; reset hour

#ad7b

#45fb

3

17

    2a 37 fd

        ld hl, (Lfd37_days)

#ad7e

#45fe

1

7

    23

        inc hl  ; increase days

#ad7f

#45ff

3

17

    22 37 fd

        ld (Lfd37_days), hl

#ad82

#4602

3

18

    cd 38 ae

        call Lae38_gain_day_resources

#ad85

#4605

    Lad85_increase_time_done:

#ad85

#4605

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#ad88

#4608

        ; Start script:

#ad88

#4608

3

            db CMD_SET_POSITION, #00, #1b

#ad8b

#460b

2

            db CMD_SET_SCALE, #00

#ad8d

#460d

2

            db CMD_SET_ATTRIBUTE, #57

#ad8f

#460f

1

            db CMD_END

#ad90

#4610

        ; End script:

#ad90

#4610

3

17

    2a 37 fd

        ld hl, (Lfd37_days)

#ad93

#4613

3

18

    cd f3 d3

        call Ld3f3_render_16bit_number

#ad96

#4616

3

18

    cd 70 d4

        call Ld470_execute_command_3_next_line

#ad99

#4619

3

14

    3a 36 fd

        ld a, (Lfd36_hours)

#ad9c

#461c

3

18

    cd ec d3

        call Ld3ec_render_8bit_number_with_leading_zeroes

#ad9f

#461f

2

8

    3e 2e

        ld a, 46

#ada1

#4621

3

18

    cd 27 d4

        call Ld427_draw_character_saving_registers

#ada4

#4624

3

14

    3a 35 fd

        ld a, (Lfd35_minutes)

#ada7

#4627

3

18

    cd ec d3

        call Ld3ec_render_8bit_number_with_leading_zeroes

#adaa

#462a

3

18

    cd 6b ae

        call Lae6b_game_over_check

#adad

#462d

2

17

    fd e5

        push iy

#adaf

#462f

4

16

    fd 21 70 fd

            ld iy, Lfd70_warbases

#adb3

#4633

2

8

    06 1c

            ld b, N_WARBASES + N_FACTORIES

#adb5

#4635

2

8

    0e 00

            ld c, 0  ; c keeps track of how many captures happened this cycle

#adb7

#4637

    Ladb7_building_loop:

#adb7

#4637

3

21

    fd 6e 00

            ld l, (iy + BUILDING_STRUCT_X)

#adba

#463a

3

21

    fd 66 01

            ld h, (iy + BUILDING_STRUCT_X + 1)

#adbd

#463d

3

21

    fd 7e 02

            ld a, (iy + BUILDING_STRUCT_Y)

#adc0

#4640

3

18

    cd a6 cc

            call Lcca6_compute_map_ptr

#adc3

#4643

2

14

    cb 76

            bit 6, (hl)  ; check if building is still there

#adc5

#4645

2

13/8

    20 06

            jr nz, Ladcd_something_in_front_of_it

#adc7

#4647

4

21

    fd 36 04 00

            ld (iy + BUILDING_STRUCT_TIMER), 0

#adcb

#464b

2

13

    18 38

            jr Lae05_next_building

#adcd

#464d

    Ladcd_something_in_front_of_it:

#adcd

#464d

3

25

    fd 34 04

            inc (iy + BUILDING_STRUCT_TIMER)

#add0

#4650

3

21

    fd 7e 04

            ld a, (iy + BUILDING_STRUCT_TIMER)

#add3

#4653

2

8

    fe 90

            cp BUILDING_CAPTURE_TIME

#add5

#4655

2

13/8

    38 2e

            jr c, Lae05_next_building

#add7

#4657

            ; Something has been in front of the factory for BUILDING_CAPTURE_TIME cycles, capture!

#add7

#4657

4

21

    fd 36 04 00

            ld (iy + BUILDING_STRUCT_TIMER), 0

#addb

#465b

1

12

    c5

            push bc

#addc

#465c

2

17

    fd e5

                push iy

#adde

#465e

3

18

    cd d8 cd

                    call Lcdd8_get_robot_at_ptr

#ade1

#4661

3

21

    fd 7e 0a

                    ld a, (iy + ROBOT_STRUCT_CONTROL)

#ade4

#4664

1

5

    07

                    rlca

#ade5

#4665

2

8

    e6 01

                    and 1

#ade7

#4667

1

5

    5f

                    ld e, a  ; here e has the robot owner (0 = player, 1 = enemy AI)

#ade8

#4668

2

16

    fd e1

                pop iy

#adea

#466a

1

5

    78

                ld a, b  ; if b == 0, no robot was found

#adeb

#466b

1

5

    b7

                or a

#adec

#466c

2

13/8

    28 16

                jr z, Lae04_next_building_pop

#adee

#466e

1

11

    c1

            pop bc

#adef

#466f

1

5

    0c

            inc c

#adf0

#4670

1

12

    c5

            push bc

#adf1

#4671

2

8

    3e 1c

                ld a, N_FACTORIES + N_WARBASES

#adf3

#4673

1

5

    90

                sub b

#adf4

#4674

2

8

    fe 04

                cp 4

#adf6

#4676

2

13/8

    30 06

                jr nc, Ladfe_factory

#adf8

#4678

1

5

    43

                ld b, e

#adf9

#4679

3

18

    cd 86 bb

                call Lbb86_assign_warbase_to_player  ; warbase captured!

#adfc

#467c

2

13

    18 06

                jr Lae04_next_building_pop

#adfe

#467e

    Ladfe_factory:

#adfe

#467e

2

8

    d6 04

                sub 4

#ae00

#4680

1

5

    43

                ld b, e

#ae01

#4681

3

18

    cd 61 bb

                call Lbb61_assign_factory_to_player  ; factory captured!

#ae04

#4684

    Lae04_next_building_pop:

#ae04

#4684

1

11

    c1

            pop bc

#ae05

#4685

    Lae05_next_building:

#ae05

#4685

            ; next building (as BUILDING_STRUCT_SIZE == 5):

#ae05

#4685

2

12

    fd 23

            inc iy

#ae07

#4687

2

12

    fd 23

            inc iy

#ae09

#4689

2

12

    fd 23

            inc iy

#ae0b

#468b

2

12

    fd 23

            inc iy

#ae0d

#468d

2

12

    fd 23

            inc iy

#ae0f

#468f

2

14/9

    10 a6

            djnz Ladb7_building_loop

#ae11

#4691

2

16

    fd e1

        pop iy

#ae13

#4693

1

5

    79

        ld a, c  ; "c" has the number of buildings captured this cycle.

#ae14

#4694

1

5

    b7

        or a

#ae15

#4695

2

13/8

    28 06

        jr z, Lae1d_no_new_captures

#ae17

#4697

3

18

    cd 09 bb

        call Lbb09_update_players_warbase_and_factory_counts

#ae1a

#469a

3

18

    cd 93 d2

        call Ld293_update_stats_in_right_hud

#ae1d

#469d

    Lae1d_no_new_captures:

#ae1d

#469d

3

14

    3a 34 fd

        ld a, (Lfd34_n_interrupts_this_came_cycle)

#ae20

#46a0

2

8

    fe 0a

        cp MIN_INTERRUPTS_PER_GAME_CYCLE

#ae22

#46a2

2

13/8

    38 f9

        jr c, Lae1d_no_new_captures  ; Loop to make sure games does not run too fast

#ae24

#46a4

1

5

    af

        xor a

#ae25

#46a5

3

14

    32 34 fd

        ld (Lfd34_n_interrupts_this_came_cycle), a

#ae28

#46a8

1

11

    c9

        ret

#ae29

#46a9

#ae29

#46a9

#ae29

#46a9

    ; --------------------------------

#ae29

#46a9

    ; Unused/unreachable code:

#ae29

#46a9

    ; - I did not find anywhere in the code that could jump here. It could be some left-over code from

#ae29

#46a9

    ;   a previous version of the game.

#ae29

#46a9

    ; - It does not make sense to jump to the BIOS address #04b0 from this game, in any case, since it

#ae29

#46a9

    ;   contains BASIC-related code. So, this code can be removed.

#ae29

#46a9

    Lae29:

#ae29

#46a9

2

8

    3e ef

        ld a, INTERFACE2_JOYSTICK_PORT_MSB

#ae2b

#46ab

2

12

    db fe

        in a, (ULA_PORT)  ; read the interface2 joystick state

#ae2d

#46ad

2

8

    e6 18

        and #18  ; button 1 or "up"

#ae2f

#46af

1

12/6

    c0

        ret nz

#ae30

#46b0

3

11

    21 00 a6

        ld hl, La600_start

#ae33

#46b3

1

12

    e5

        push hl

#ae34

#46b4

1

5

    f3

        di

#ae35

#46b5

3

11

    c3 b0 04

        jp #04b0

#ae38

#46b8

#ae38

#46b8

#ae38

#46b8

    ; --------------------------------

#ae38

#46b8

    ; Update the resources each player has adding their daily gains, and updates the hud.

#ae38

#46b8

    Lae38_gain_day_resources:

#ae38

#46b8

3

11

    21 22 fd

        ld hl, Lfd22_player1_resource_counts

#ae3b

#46bb

3

11

    11 3a fd

        ld de, Lfd3a_player1_base_factory_counts

#ae3e

#46be

3

18

    cd 4e ae

        call Lae4e_gain_day_resources_player

#ae41

#46c1

3

11

    21 4a fd

        ld hl, Lfd4a_player2_resource_counts

#ae44

#46c4

3

11

    11 42 fd

        ld de, Lfd42_player2_base_factory_counts

#ae47

#46c7

3

18

    cd 4e ae

        call Lae4e_gain_day_resources_player

#ae4a

#46ca

3

18

    cd 93 d2

        call Ld293_update_stats_in_right_hud

#ae4d

#46cd

1

11

    c9

        ret

#ae4e

#46ce

#ae4e

#46ce

#ae4e

#46ce

    ; --------------------------------

#ae4e

#46ce

    ; - adds 5 times the number of bases to the general resources

#ae4e

#46ce

    ; - adds 2 times the number of factories of each type to the part-specific resources

#ae4e

#46ce

    ; input:

#ae4e

#46ce

    ; - de: pointer to the # of bases and factories of a given player

#ae4e

#46ce

    ; - hl: pointer to the resources of a given player

#ae4e

#46ce

    Lae4e_gain_day_resources_player:

#ae4e

#46ce

1

8

    1a

        ld a, (de)

#ae4f

#46cf

1

5

    4f

        ld c, a

#ae50

#46d0

1

5

    87

        add a, a

#ae51

#46d1

1

5

    87

        add a, a

#ae52

#46d2

1

5

    81

        add a, c  ; a = (de)*5

#ae53

#46d3

3

18

    cd 62 ae

        call Lae62_add_limit_100  ; (hl) += (de)*5

#ae56

#46d6

2

8

    06 06

        ld b, 6

#ae58

#46d8

    Lae58_factory_loop:

#ae58

#46d8

1

7

    23

        inc hl

#ae59

#46d9

1

7

    13

        inc de

#ae5a

#46da

1

8

    1a

        ld a, (de)

#ae5b

#46db

1

5

    87

        add a, a

#ae5c

#46dc

3

18

    cd 62 ae

        call Lae62_add_limit_100

#ae5f

#46df

2

14/9

    10 f7

        djnz Lae58_factory_loop

#ae61

#46e1

1

11

    c9

        ret

#ae62

#46e2

#ae62

#46e2

#ae62

#46e2

    ; --------------------------------

#ae62

#46e2

    ; Adds a to (hl), keeping the result smaller than 100

#ae62

#46e2

    Lae62_add_limit_100:

#ae62

#46e2

1

8

    86

        add a, (hl)

#ae63

#46e3

2

8

    fe 64

        cp 100

#ae65

#46e5

2

13/8

    38 02

        jr c, Lae69_smaller_than_100

#ae67

#46e7

2

8

    3e 63

        ld a, 99

#ae69

#46e9

    Lae69_smaller_than_100:

#ae69

#46e9

1

8

    77

        ld (hl), a

#ae6a

#46ea

1

11

    c9

        ret

#ae6b

#46eb

#ae6b

#46eb

#ae6b

#46eb

    ; --------------------------------

#ae6b

#46eb

    ; Checks if one of the players does not have any bases left,

#ae6b

#46eb

    ; and shows the victory or defeat messages.

#ae6b

#46eb

    Lae6b_game_over_check:

#ae6b

#46eb

3

14

    3a 42 fd

        ld a, (Lfd42_player2_base_factory_counts)

#ae6e

#46ee

1

5

    b7

        or a

#ae6f

#46ef

2

13/8

    28 40

        jr z, Laeb1_game_over_victory

#ae71

#46f1

3

14

    3a 3a fd

        ld a, (Lfd3a_player1_base_factory_counts)

#ae74

#46f4

1

5

    b7

        or a

#ae75

#46f5

1

12/6

    c0

        ret nz

#ae76

#46f6

        ; Game over defeat:

#ae76

#46f6

3

18

    cd 00 af

        call Laf00_set_default_hud_and_empty_interrupt

#ae79

#46f9

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#ae7c

#46fc

        ; script start:

#ae7c

#46fc

3

            db CMD_SET_POSITION, 22, 0

#ae7f

#46ff

2

            db CMD_SET_ATTRIBUTE, 69

#ae81

#4701

22

            db "YOU HAVE NO BASES LEFT"

#ae97

#4717

1

            db CMD_NEXT_LINE

#ae98

#4718

22

            db "BETTER LUCK NEXT TIME!"

#aeae

#472e

1

            db CMD_END

#aeaf

#472f

        ; script end:

#aeaf

#472f

2

13

    18 39

        jr Laeea_game_over_message_drawn

#aeb1

#4731

    Laeb1_game_over_victory:

#aeb1

#4731

3

18

    cd 00 af

        call Laf00_set_default_hud_and_empty_interrupt

#aeb4

#4734

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#aeb7

#4737

        ; script start:

#aeb7

#4737

3

            db CMD_SET_POSITION, 22, 0

#aeba

#473a

2

            db CMD_SET_ATTRIBUTE, 69

#aebc

#473c

22

            db " INSIGNIANS DESTROYED "

#aed2

#4752

1

            db CMD_NEXT_LINE

#aed3

#4753

22

            db "    YOU HAVE WON !    "

#aee9

#4769

1

            db CMD_END

#aeea

#476a

        ; script end:

#aeea

#476a

    Laeea_game_over_message_drawn:

#aeea

#476a

        ; Produce a sound, wait for player to press some key, and restart the game.

#aeea

#476a

2

8

    3e fa

        ld a, 250

#aeec

#476c

3

18

    cd ac cc

        call Lccac_beep

#aeef

#476f

2

8

    06 64

        ld b, 100  ; wait 2 seconds

#aef1

#4771

    Laef1_wait_loop:

#aef1

#4771

1

5

    76

        halt

#aef2

#4772

2

14/9

    10 fd

        djnz Laef1_wait_loop

#aef4

#4774

3

18

    cd 57 ad

        call Lad57_wait_until_no_keys_pressed

#aef7

#4777

    Laef7_wait_for_any_key:

#aef7

#4777

3

18

    cd 7c d3

        call Ld37c_read_keyboard_joystick_input

#aefa

#477a

1

5

    b7

        or a

#aefb

#477b

2

13/8

    28 fa

        jr z, Laef7_wait_for_any_key

#aefd

#477d

3

11

    c3 00 a6

        jp La600_start

#af00

#4780

#af00

#4780

    Laf00_set_default_hud_and_empty_interrupt:

#af00

#4780

1

5

    af

        xor a

#af01

#4781

3

14

    32 39 fd

        ld (Lfd39_current_in_game_right_hud), a

#af04

#4784

3

18

    cd f6 d2

        call Ld2f6_clear_in_game_right_hud  ; Potential optimization: not needed, as this is already

#af07

#4787

                                            ; called in the function below

#af07

#4787

3

18

    cd e5 d1

        call Ld1e5_draw_in_game_right_hud

#af0a

#478a

3

11

    21 9c d5

        ld hl, Ld59c_empty_interrupt

#af0d

#478d

3

17

    22 fe fd

        ld (Lfdfe_interrupt_pointer), hl

#af10

#4790

1

11

    c9

        ret

#af11

#4791

#af11

#4791

#af11

#4791

    ; --------------------------------

#af11

#4791

    ; Controls the player ship using keyboard.

#af11

#4791

    Laf11_player_ship_keyboard_control:

#af11

#4791

3

18

    cd 1d b0

        call Lb01d_remove_player_from_map

#af14

#4794

        ; If the player is pressing up/down, reduce the effect of Lfd30_player_elevate_timer:

#af14

#4794

3

14

    3a 0c fd

        ld a, (Lfd0c_keyboard_state)

#af17

#4797

2

8

    e6 0c

        and #0c  ; down/up

#af19

#4799

2

13/8

    28 0a

        jr z, Laf25_player_ship_keyboard_control_x  ; Potential optimization: the following lines

#af1b

#479b

                                                    ; implement a random behavior (reduce elevate timer

#af1b

#479b

                                                    ; if you are pressing up/down) that can be removed.

#af1b

#479b

3

14

    3a 30 fd

        ld a, (Lfd30_player_elevate_timer)

#af1e

#479e

1

5

    b7

        or a

#af1f

#479f

2

13/8

    28 04

        jr z, Laf25_player_ship_keyboard_control_x

#af21

#47a1

1

5

    3d

        dec a

#af22

#47a2

3

14

    32 30 fd

        ld (Lfd30_player_elevate_timer), a

#af25

#47a5

#af25

#47a5

    Laf25_player_ship_keyboard_control_x:

#af25

#47a5

3

14

    3a 0c fd

        ld a, (Lfd0c_keyboard_state)

#af28

#47a8

2

8

    e6 03

        and #03

#af2a

#47aa

2

13/8

    28 4b

        jr z, Laf77_player_ship_keyboard_control_y  ; if left/right are not pressed

#af2c

#47ac

2

8

    fe 03

        cp 3

#af2e

#47ae

2

13/8

    28 47

        jr z, Laf77_player_ship_keyboard_control_y  ; if left/right are pressed simultaneously

#af30

#47b0

3

17

    2a 0e fd

        ld hl, (Lfd0e_player_x)

#af33

#47b3

1

5

    0f

        rrca

#af34

#47b4

2

13/8

    38 0c

        jr c, Laf42_move_right

#af36

#47b6

        ; Move left:

#af36

#47b6

1

5

    7c

        ld a, h

#af37

#47b7

1

5

    b7

        or a

#af38

#47b8

2

13/8

    20 05

        jr nz, Laf3f

#af3a

#47ba

1

5

    7d

        ld a, l

#af3b

#47bb

2

8

    fe 0e

        cp MIN_PLAYER_X

#af3d

#47bd

2

13/8

    28 38

        jr z, Laf77_player_ship_keyboard_control_y

#af3f

#47bf

    Laf3f:

#af3f

#47bf

1

7

    2b

        dec hl

#af40

#47c0

2

13

    18 0a

        jr Laf4c_move_player_if_no_collision

#af42

#47c2

    Laf42_move_right:

#af42

#47c2

1

5

    7c

        ld a, h

#af43

#47c3

1

5

    b7

        or a

#af44

#47c4

2

13/8

    28 05

        jr z, Laf4b

#af46

#47c6

1

5

    7d

        ld a, l

#af47

#47c7

2

8

    fe f5

        cp MAX_PLAYER_X - 256

#af49

#47c9

2

13/8

    28 2c

        jr z, Laf77_player_ship_keyboard_control_y

#af4b

#47cb

    Laf4b:

#af4b

#47cb

1

7

    23

        inc hl

#af4c

#47cc

    Laf4c_move_player_if_no_collision:

#af4c

#47cc

3

14

    3a 0d fd

        ld a, (Lfd0d_player_y)

#af4f

#47cf

3

18

    cd 52 b0

        call Lb052_check_player_collision

#af52

#47d2

2

13/8

    38 03

        jr c, Laf57_collision

#af54

#47d4

3

17

    22 0e fd

        ld (Lfd0e_player_x), hl

#af57

#47d7

    Laf57_collision:

#af57

#47d7

        ; See if we need to scroll the map:

#af57

#47d7

3

17

    2a 0e fd

        ld hl, (Lfd0e_player_x)

#af5a

#47da

4

22

    ed 5b 0a fd

        ld de, (Lfd0a_scroll_x)

#af5e

#47de

1

5

    af

        xor a

#af5f

#47df

2

17

    ed 52

        sbc hl, de

#af61

#47e1

1

5

    7d

        ld a, l

#af62

#47e2

2

8

    fe 0d

        cp 13  ; player in the left screen edge

#af64

#47e4

2

13/8

    20 01

        jr nz, Laf67_no_scroll_left

#af66

#47e6

1

7

    1b

        dec de

#af67

#47e7

    Laf67_no_scroll_left:

#af67

#47e7

2

8

    fe 16

        cp 22  ; player in the right screen edge

#af69

#47e9

2

13/8

    20 01

        jr nz, Laf6c_no_scroll_right

#af6b

#47eb

1

7

    13

        inc de

#af6c

#47ec

    Laf6c_no_scroll_right:

#af6c

#47ec

4

22

    ed 53 0a fd

        ld (Lfd0a_scroll_x), de

#af70

#47f0

3

11

    21 00 dd

        ld hl, Ldd00_map

#af73

#47f3

1

12

    19

        add hl, de

#af74

#47f4

3

17

    22 06 fd

        ld (Lfd06_scroll_ptr), hl

#af77

#47f7

#af77

#47f7

    Laf77_player_ship_keyboard_control_y:

#af77

#47f7

3

14

    3a 0d fd

        ld a, (Lfd0d_player_y)

#af7a

#47fa

1

5

    4f

        ld c, a

#af7b

#47fb

3

14

    3a 0c fd

        ld a, (Lfd0c_keyboard_state)

#af7e

#47fe

1

5

    0f

        rrca

#af7f

#47ff

1

5

    0f

        rrca

#af80

#4800

2

8

    e6 03

        and #03

#af82

#4802

2

13/8

    28 1e

        jr z, Lafa2_player_ship_keyboard_control_altitude  ; up/down not pressed

#af84

#4804

2

8

    fe 03

        cp 3

#af86

#4806

2

13/8

    28 1a

        jr z, Lafa2_player_ship_keyboard_control_altitude  ; up/down pressed simultaneously

#af88

#4808

1

5

    0f

        rrca

#af89

#4809

2

13/8

    30 01

        jr nc, Laf8c_no_move_down  ; no move down

#af8b

#480b

1

5

    0c

        inc c

#af8c

#480c

    Laf8c_no_move_down:

#af8c

#480c

1

5

    0f

        rrca

#af8d

#480d

2

13/8

    30 01

        jr nc, Laf90_no_move_up

#af8f

#480f

1

5

    0d

        dec c

#af90

#4810

    Laf90_no_move_up:

#af90

#4810

1

5

    79

        ld a, c

#af91

#4811

2

8

    e6 0f

        and #0f

#af93

#4813

2

13/8

    28 0d

        jr z, Lafa2_player_ship_keyboard_control_altitude  ; do not go beyond map borders

#af95

#4815

3

17

    2a 0e fd

        ld hl, (Lfd0e_player_x)

#af98

#4818

1

5

    47

        ld b, a

#af99

#4819

3

18

    cd 52 b0

        call Lb052_check_player_collision

#af9c

#481c

2

13/8

    38 04

        jr c, Lafa2_player_ship_keyboard_control_altitude  ; collision

#af9e

#481e

1

5

    78

        ld a, b

#af9f

#481f

3

14

    32 0d fd

        ld (Lfd0d_player_y), a

#afa2

#4822

#afa2

#4822

    Lafa2_player_ship_keyboard_control_altitude:

#afa2

#4822

3

14

    3a 30 fd

        ld a, (Lfd30_player_elevate_timer)

#afa5

#4825

1

5

    b7

        or a

#afa6

#4826

2

13/8

    28 06

        jr z, Lafae_no_auto_elevate

#afa8

#4828

1

5

    3d

        dec a

#afa9

#4829

3

14

    32 30 fd

        ld (Lfd30_player_elevate_timer), a

#afac

#482c

2

13

    18 07

        jr Lafb5_elevate

#afae

#482e

    Lafae_no_auto_elevate:

#afae

#482e

3

14

    3a 0c fd

        ld a, (Lfd0c_keyboard_state)

#afb1

#4831

2

8

    e6 10

        and #10

#afb3

#4833

2

13/8

    28 0e

        jr z, Lafc3_gravity

#afb5

#4835

    Lafb5_elevate:

#afb5

#4835

3

14

    3a 10 fd

        ld a, (Lfd10_player_altitude)

#afb8

#4838

2

8

    fe 30

        cp MAX_PLAYER_ALTITUDE

#afba

#483a

2

13/8

    30 1f

        jr nc, Lafdb_continue

#afbc

#483c

2

8

    c6 02

        add a, 2

#afbe

#483e

3

14

    32 10 fd

        ld (Lfd10_player_altitude), a

#afc1

#4841

2

13

    18 18

        jr Lafdb_continue

#afc3

#4843

#afc3

#4843

    Lafc3_gravity:

#afc3

#4843

3

14

    3a 10 fd

        ld a, (Lfd10_player_altitude)

#afc6

#4846

1

5

    3d

        dec a  ; Player ship falls with gravity

#afc7

#4847

3

11

    fa db af

        jp m, Lafdb_continue

#afca

#484a

1

5

    47

        ld b, a

#afcb

#484b

3

14

    3a 0d fd

        ld a, (Lfd0d_player_y)

#afce

#484e

3

17

    2a 0e fd

        ld hl, (Lfd0e_player_x)

#afd1

#4851

3

18

    cd 52 b0

        call Lb052_check_player_collision

#afd4

#4854

1

5

    78

        ld a, b

#afd5

#4855

1

5

    b9

        cp c

#afd6

#4856

2

13/8

    38 03

        jr c, Lafdb_continue  ; collision when going down

#afd8

#4858

3

14

    32 10 fd

        ld (Lfd10_player_altitude), a

#afdb

#485b

#afdb

#485b

    Lafdb_continue:

#afdb

#485b

3

18

    cd e6 af

        call Lafe6_radar_scroll

#afde

#485e

3

11

    21 1e fd

        ld hl, Lfd1e_player_visible_in_radar  ; Potential optimization: are these last lines needed? (

#afe1

#4861

                                              ; this is already done in "Lb048_update_radar" each

#afe1

#4861

                                              ; cycle, so, maybe this just does even more blinking).

#afe1

#4861

1

12

    34

        inc (hl)

#afe2

#4862

3

18

    cd 24 b0

        call Lb024_add_player_to_map_and_update_radar  ; Potential optimization: tail recursion.

#afe5

#4865

1

11

    c9

        ret

#afe6

#4866

#afe6

#4866

#afe6

#4866

    ; --------------------------------

#afe6

#4866

    ; Check if we need to scroll the radar screen due to player movement.

#afe6

#4866

    Lafe6_radar_scroll:

#afe6

#4866

3

17

    2a 0e fd

        ld hl, (Lfd0e_player_x)

#afe9

#4869

3

14

    3a 1b fd

        ld a, (Lfd1b_radar_scroll_x_tile)

#afec

#486c

1

5

    4f

        ld c, a

#afed

#486d

1

5

    7d

        ld a, l

#afee

#486e

2

10

    cb 1c

        rr h

#aff0

#4870

1

5

    1f

        rra

#aff1

#4871

2

10

    cb 3f

        srl a

#aff3

#4873

2

10

    cb 3f

        srl a  ; a = (Lfd0e_player_x) / 8

#aff5

#4875

1

5

    91

        sub c  ; c = (Lfd0e_player_x) / 8 - (Lfd1b_radar_scroll_x_tile)

#aff6

#4876

2

8

    fe 02

        cp 2  ; if we are in the left-edge, scroll left

#aff8

#4878

2

13/8

    38 05

        jr c, Lafff_radar_scroll_left

#affa

#487a

2

8

    fe 0e

        cp 14  ; if we are in the right-edge, scroll right

#affc

#487c

2

13/8

    30 07

        jr nc, Lb005_radar_scroll_right

#affe

#487e

1

11

    c9

        ret

#afff

#487f

    Lafff_radar_scroll_left:

#afff

#487f

1

5

    79

        ld a, c

#b000

#4880

2

8

    d6 08

        sub 8

#b002

#4882

1

12/6

    f8

        ret m

#b003

#4883

2

13

    18 06

        jr Lb00b_update_radar_scroll

#b005

#4885

    Lb005_radar_scroll_right:

#b005

#4885

1

5

    79

        ld a, c

#b006

#4886

2

8

    c6 08

        add a, 8

#b008

#4888

2

8

    fe 38

        cp 56

#b00a

#488a

1

12/6

    c8

        ret z

#b00b

#488b

    Lb00b_update_radar_scroll:

#b00b

#488b

3

14

    32 1b fd

        ld (Lfd1b_radar_scroll_x_tile), a

#b00e

#488e

1

5

    87

        add a, a

#b00f

#488f

1

5

    87

        add a, a

#b010

#4890

1

5

    6f

        ld l, a

#b011

#4891

2

8

    26 00

        ld h, 0

#b013

#4893

1

12

    29

        add hl, hl

#b014

#4894

3

17

    22 1c fd

        ld (Lfd1c_radar_scroll_x), hl

#b017

#4897

2

8

    3e 01

        ld a, 1

#b019

#4899

3

14

    32 52 fd

        ld (Lfd52_update_radar_buffer_signal), a

#b01c

#489c

1

11

    c9

        ret

#b01d

#489d

#b01d

#489d

#b01d

#489d

    ; --------------------------------

#b01d

#489d

    ; Removes the player from the map (bit 7), and then draws the player in the radar view.

#b01d

#489d

    Lb01d_remove_player_from_map:

#b01d

#489d

3

18

    cd a0 cc

        call Lcca0_compute_player_map_ptr

#b020

#48a0

2

17

    cb be

        res 7, (hl)  ; mark player is no longer here

#b022

#48a2

2

13

    18 12

        jr Lb036_flicker_player_in_radar

#b024

#48a4

#b024

#48a4

#b024

#48a4

    ; --------------------------------

#b024

#48a4

    ; Marks that the player is in the map (bit 7), and

#b024

#48a4

    ; also updates the radar buffers with buildings/robots and player.

#b024

#48a4

    Lb024_add_player_to_map_and_update_radar:

#b024

#48a4

3

18

    cd a0 cc

        call Lcca0_compute_player_map_ptr

#b027

#48a7

2

17

    cb fe

        set 7, (hl)  ; mark player is here

#b029

#48a9

    Lb029_update_radar_view_if_necessary:

#b029

#48a9

        ; Update the radar view if necessary:

#b029

#48a9

3

14

    3a 52 fd

        ld a, (Lfd52_update_radar_buffer_signal)

#b02c

#48ac

1

5

    b7

        or a

#b02d

#48ad

2

13/8

    28 07

        jr z, Lb036_flicker_player_in_radar

#b02f

#48af

3

18

    cd f8 d5

        call Ld5f8_update_radar_buffers

#b032

#48b2

1

5

    af

        xor a

#b033

#48b3

3

14

    32 52 fd

        ld (Lfd52_update_radar_buffer_signal), a

#b036

#48b6

    Lb036_flicker_player_in_radar:

#b036

#48b6

3

14

    3a 1e fd

        ld a, (Lfd1e_player_visible_in_radar)

#b039

#48b9

2

8

    e6 01

        and 1

#b03b

#48bb

1

12/6

    c8

        ret z  ; Do not draw player in radar

#b03c

#48bc

3

17

    2a 0e fd

        ld hl, (Lfd0e_player_x)

#b03f

#48bf

3

14

    3a 0d fd

        ld a, (Lfd0d_player_y)

#b042

#48c2

1

5

    4f

        ld c, a

#b043

#48c3

2

8

    06 00

        ld b, 0

#b045

#48c5

3

11

    c3 5a d6

        jp Ld65a_flip_2x2_radar_area

#b048

#48c8

#b048

#48c8

#b048

#48c8

    ; --------------------------------

#b048

#48c8

    ; Increments whether the player is visible in the radar or not, and updates the radar.

#b048

#48c8

    Lb048_update_radar:

#b048

#48c8

3

18

    cd 36 b0

        call Lb036_flicker_player_in_radar

#b04b

#48cb

3

11

    21 1e fd

        ld hl, Lfd1e_player_visible_in_radar

#b04e

#48ce

1

12

    34

        inc (hl)

#b04f

#48cf

3

11

    c3 29 b0

        jp Lb029_update_radar_view_if_necessary

#b052

#48d2

#b052

#48d2

#b052

#48d2

    ; --------------------------------

#b052

#48d2

    ; Checks whether there would be a collision with the player altitude in a 3x3 area

#b052

#48d2

    ; centered around a given set of coordinates:

#b052

#48d2

    ; Input:

#b052

#48d2

    ; - hl: x

#b052

#48d2

    ; - a: y

#b052

#48d2

    ; Return:

#b052

#48d2

    ; - carry flag: set for collision, unset for no collision.

#b052

#48d2

    Lb052_check_player_collision:

#b052

#48d2

1

12

    e5

        push hl

#b053

#48d3

3

18

    cd a6 cc

            call Lcca6_compute_map_ptr

#b056

#48d6

1

5

    eb

            ex de, hl

#b057

#48d7

2

8

    0e 00

            ld c, 0

#b059

#48d9

3

18

    cd 96 b0

            call Lb096_get_map_altitude_including_robots_and_decorations

#b05c

#48dc

1

7

    13

            inc de  ; x += 1

#b05d

#48dd

3

18

    cd 96 b0

            call Lb096_get_map_altitude_including_robots_and_decorations

#b060

#48e0

1

5

    15

            dec d

#b061

#48e1

1

5

    15

            dec d  ; y -= 1

#b062

#48e2

3

18

    cd 96 b0

            call Lb096_get_map_altitude_including_robots_and_decorations

#b065

#48e5

1

7

    1b

            dec de  ; x -= 1

#b066

#48e6

3

18

    cd 96 b0

            call Lb096_get_map_altitude_including_robots_and_decorations

#b069

#48e9

1

7

    1b

            dec de  ; x -= 1

#b06a

#48ea

3

18

    cd 99 b0

            call Lb099_get_robot_or_decoration_altitude

#b06d

#48ed

1

5

    14

            inc d

#b06e

#48ee

1

5

    14

            inc d  ; y += 1

#b06f

#48ef

3

18

    cd 99 b0

            call Lb099_get_robot_or_decoration_altitude

#b072

#48f2

1

5

    14

            inc d

#b073

#48f3

1

5

    14

            inc d  ; y += 1

#b074

#48f4

1

5

    7a

            ld a, d

#b075

#48f5

2

8

    fe fd

            cp #fd  ; edge of the map

#b077

#48f7

2

13/8

    30 0b

            jr nc, Lb084

#b079

#48f9

3

18

    cd 99 b0

            call Lb099_get_robot_or_decoration_altitude

#b07c

#48fc

1

7

    13

            inc de  ; x += 1

#b07d

#48fd

3

18

    cd 99 b0

            call Lb099_get_robot_or_decoration_altitude

#b080

#4900

1

7

    13

            inc de  ; x += 1

#b081

#4901

3

18

    cd 99 b0

            call Lb099_get_robot_or_decoration_altitude

#b084

#4904

    Lb084:

#b084

#4904

3

14

    3a 10 fd

            ld a, (Lfd10_player_altitude)

#b087

#4907

1

5

    b9

            cp c

#b088

#4908

1

11

    e1

        pop hl

#b089

#4909

1

11

    c9

        ret

#b08a

#490a

#b08a

#490a

#b08a

#490a

    ; --------------------------------

#b08a

#490a

    ; Gets the altitude of a position in the map, and if it is higher

#b08a

#490a

    ; than the current of value in "c", it gets updated.

#b08a

#490a

    ; Input:

#b08a

#490a

    ; - de: map pointer

#b08a

#490a

    ; Output:

#b08a

#490a

    ; - a: map altitude

#b08a

#490a

    ; - c: max of "c" and map altitude in "de".

#b08a

#490a

    Lb08a_get_map_altitude:

#b08a

#490a

1

8

    1a

        ld a, (de)

#b08b

#490b

2

8

    e6 1f

        and #1f

#b08d

#490d

3

11

    21 bc d7

        ld hl, Ld7bc_map_piece_heights

#b090

#4910

3

18

    cd 51 d3

        call Ld351_add_hl_a

#b093

#4913

1

8

    7e

        ld a, (hl)

#b094

#4914

2

13

    18 15

        jr Lb0ab_max_of_a_and_c

#b096

#4916

#b096

#4916

#b096

#4916

    ; --------------------------------

#b096

#4916

    ; Gets the altitude at a particular position, including robots and decorations.

#b096

#4916

    ; Input:

#b096

#4916

    ; - de: map pointer

#b096

#4916

    ; - c: initial altitude

#b096

#4916

    ; Output:

#b096

#4916

    ; - c: max of "c" and map altitude in "de" (including robots and decorations).

#b096

#4916

    Lb096_get_map_altitude_including_robots_and_decorations:

#b096

#4916

3

18

    cd 8a b0

        call Lb08a_get_map_altitude

#b099

#4919

    Lb099_get_robot_or_decoration_altitude:

#b099

#4919

1

5

    62

        ld h, d

#b09a

#491a

1

5

    6b

        ld l, e

#b09b

#491b

2

14

    cb 76

        bit 6, (hl)

#b09d

#491d

1

12/6

    c8

        ret z

#b09e

#491e

1

12

    c5

        push bc

#b09f

#491f

3

18

    cd d8 cd

            call Lcdd8_get_robot_at_ptr

#b0a2

#4922

2

13/8

    20 0c

            jr nz, Lb0b0_get_decoration_altitude

#b0a4

#4924

1

11

    c1

        pop bc

#b0a5

#4925

3

21

    fd 7e 09

        ld a, (iy + ROBOT_STRUCT_HEIGHT)

#b0a8

#4928

3

21

    fd 86 0d

        add a, (iy + ROBOT_STRUCT_ALTITUDE)

#b0ab

#492b

        ; jp Lb0ab_max_of_a_and_c

#b0ab

#492b

#b0ab

#492b

#b0ab

#492b

    ; --------------------------------

#b0ab

#492b

    ; c = max(c, a)

#b0ab

#492b

    Lb0ab_max_of_a_and_c:

#b0ab

#492b

1

5

    b9

        cp c

#b0ac

#492c

2

13/8

    38 01

        jr c, Lb0af_c_larger

#b0ae

#492e

1

5

    4f

        ld c, a

#b0af

#492f

    Lb0af_c_larger:

#b0af

#492f

1

11

    c9

        ret

#b0b0

#4930

#b0b0

#4930

#b0b0

#4930

    ; --------------------------------

#b0b0

#4930

    ; Gets the altitude of a decoration (like a "flag") if present.

#b0b0

#4930

    ; Input:

#b0b0

#4930

    ; - de: map pointer

#b0b0

#4930

    ; - c: initial altitude

#b0b0

#4930

    ; Output:

#b0b0

#4930

    ; - c: max of "c" and decoration altitude in "de" if present.

#b0b0

#4930

    Lb0b0_get_decoration_altitude:

#b0b0

#4930

3

18

    cd f5 cd

            call Lcdf5_find_building_decoration_with_ptr

#b0b3

#4933

1

11

    c1

        pop bc

#b0b4

#4934

1

12/6

    c0

        ret nz

#b0b5

#4935

3

21

    fd 7e 02

        ld a, (iy + BUILDING_DECORATION_STRUCT_TYPE)

#b0b8

#4938

3

11

    21 c1 b0

        ld hl, Lb0c1_decoration_altitudes

#b0bb

#493b

3

18

    cd 51 d3

        call Ld351_add_hl_a

#b0be

#493e

1

8

    7e

        ld a, (hl)

#b0bf

#493f

2

13

    18 ea

        jr Lb0ab_max_of_a_and_c

#b0c1

#4941

#b0c1

#4941

    Lb0c1_decoration_altitudes:

#b0c1

#4941

1

        db #0f  ; warbase "H"

#b0c2

#4942

6

        db #16, #15, #15, #16, #16, #16  ; pieces on top of factories

#b0c8

#4948

2

        db #19, #19  ; flags

#b0ca

#494a

#b0ca

#494a

#b0ca

#494a

    ; --------------------------------

#b0ca

#494a

    ; Executes one update cycle for each robot and bullet in the game.

#b0ca

#494a

    Lb0ca_update_robots_bullets_and_ai:

#b0ca

#494a

3

18

    cd f4 b7

        call Lb7f4_update_enemy_ai

#b0cd

#494d

2

8

    06 30

        ld b, MAX_ROBOTS_PER_PLAYER * 2

#b0cf

#494f

4

16

    fd 21 00 da

        ld iy, Lda00_player1_robots

#b0d3

#4953

    Lb0d3_robot_update_loop:

#b0d3

#4953

1

12

    c5

        push bc

#b0d4

#4954

3

21

    fd 7e 01

            ld a, (iy + 1)

#b0d7

#4957

1

5

    b7

            or a

#b0d8

#4958

3

18/11

    c4 fa b0

            call nz, Lb0fa_robot_update  ; If robot is not destroyed, execute one update cycle

#b0db

#495b

3

11

    11 10 00

            ld de, ROBOT_STRUCT_SIZE

#b0de

#495e

2

17

    fd 19

            add iy, de

#b0e0

#4960

1

11

    c1

        pop bc

#b0e1

#4961

2

14/9

    10 f0

        djnz Lb0d3_robot_update_loop

#b0e3

#4963

4

16

    fd 21 d3 d7

        ld iy, Ld7d3_bullets

#b0e7

#4967

2

8

    06 05

        ld b, MAX_BULLETS

#b0e9

#4969

    Lb0e9_bullet_update_loop:

#b0e9

#4969

1

12

    c5

        push bc

#b0ea

#496a

3

21

    fd 7e 01

            ld a, (iy + 1)

#b0ed

#496d

1

5

    b7

            or a

#b0ee

#496e

3

18/11

    c4 0d b7

            call nz, Lb70d_bullet_update  ; If there is a bullet, execute one update cycle

#b0f1

#4971

3

11

    11 09 00

            ld de, BULLET_STRUCT_SIZE

#b0f4

#4974

2

17

    fd 19

            add iy, de

#b0f6

#4976

1

11

    c1

        pop bc

#b0f7

#4977

2

14/9

    10 f0

        djnz Lb0e9_bullet_update_loop

#b0f9

#4979

1

11

    c9

        ret

#b0fa

#497a

#b0fa

#497a

#b0fa

#497a

    ; --------------------------------

#b0fa

#497a

    ; Update cycle of a robot, checking if it has to be destroyed or not.

#b0fa

#497a

    Lb0fa_robot_update:

#b0fa

#497a

3

21

    fd 7e 0c

        ld a, (iy + ROBOT_STRUCT_STRENGTH)

#b0fd

#497d

1

5

    b7

        or a

#b0fe

#497e

2

13/8

    28 16

        jr z, Lb116_robot_destroyed

#b100

#4980

3

11

    f2 54 b1

        jp p, Lb154_robot_ai_update

#b103

#4983

        ; negative energy: robot is destroyed, so we are just going to make it blink

#b103

#4983

3

25

    fd 34 0c

        inc (iy + ROBOT_STRUCT_STRENGTH)

#b106

#4986

3

21

    fd 6e 00

        ld l, (iy + ROBOT_STRUCT_MAP_PTR)

#b109

#4989

3

21

    fd 66 01

        ld h, (iy + ROBOT_STRUCT_MAP_PTR + 1)

#b10c

#498c

2

8

    e6 01

        and 1

#b10e

#498e

2

13/8

    20 03

        jr nz, Lb113

#b110

#4990

2

17

    cb b6

        res 6, (hl)  ; blink out

#b112

#4992

1

11

    c9

        ret

#b113

#4993

    Lb113:

#b113

#4993

2

17

    cb f6

        set 6, (hl)  ; blink in

#b115

#4995

1

11

    c9

        ret

#b116

#4996

    Lb116_robot_destroyed:

#b116

#4996

3

21

    fd 6e 00

        ld l, (iy + ROBOT_STRUCT_MAP_PTR)

#b119

#4999

3

21

    fd 66 01

        ld h, (iy + ROBOT_STRUCT_MAP_PTR + 1)

#b11c

#499c

2

17

    cb b6

        res 6, (hl)  ; remove the mark in the map

#b11e

#499e

        ; Check if there is something in the map or not. If there is nothing in the  map,

#b11e

#499e

        ; we will add some random garbage.

#b11e

#499e

1

8

    7e

        ld a, (hl)

#b11f

#499f

1

7

    23

        inc hl

#b120

#49a0

1

8

    b6

        or (hl)

#b121

#49a1

1

5

    25

        dec h

#b122

#49a2

1

5

    25

        dec h

#b123

#49a3

1

8

    b6

        or (hl)

#b124

#49a4

1

7

    2b

        dec hl

#b125

#49a5

1

8

    b6

        or (hl)

#b126

#49a6

1

5

    24

        inc h

#b127

#49a7

1

5

    24

        inc h

#b128

#49a8

2

8

    e6 3f

        and #3f

#b12a

#49aa

2

13/8

    20 0a

        jr nz, Lb136_map_not_empty  ; There is something in the map

#b12c

#49ac

3

18

    cd 58 d3

        call Ld358_random

#b12f

#49af

2

8

    e6 01

        and 1

#b131

#49b1

2

8

    c6 06

        add a, 6

#b133

#49b3

3

18

    cd 91 bd

        call Lbd91_add_element_to_map  ; Add some debris to the map

#b136

#49b6

    Lb136_map_not_empty:

#b136

#49b6

3

21

    fd 6e 02

        ld l, (iy + ROBOT_STRUCT_X)

#b139

#49b9

3

21

    fd 66 03

        ld h, (iy + ROBOT_STRUCT_X + 1)

#b13c

#49bc

3

21

    fd 4e 04

        ld c, (iy + ROBOT_STRUCT_Y)

#b13f

#49bf

3

21

    fd 7e 0a

        ld a, (iy + ROBOT_STRUCT_CONTROL)

#b142

#49c2

1

5

    07

        rlca

#b143

#49c3

2

8

    e6 01

        and 1

#b145

#49c5

1

5

    47

        ld b, a  ; b = 0 if it's a player robot, and b = 1 if it's an enemy AI robot.

#b146

#49c6

3

18

    cd 5a d6

        call Ld65a_flip_2x2_radar_area  ; remove robot out of the map

#b149

#49c9

4

21

    fd 36 01 00

        ld (iy + 1), 0  ; mark the robot as removed

#b14d

#49cd

3

18

    cd 40 bb

        call Lbb40_count_robots

#b150

#49d0

3

18

    cd 93 d2

        call Ld293_update_stats_in_right_hud  ; Potential optimization: tail recursion.

#b153

#49d3

1

11

    c9

        ret

#b154

#49d4

#b154

#49d4

#b154

#49d4

    ; --------------------------------

#b154

#49d4

    ; Update cycle for robots behavior.

#b154

#49d4

    ; Input:

#b154

#49d4

    ; - iy: robot ptr.

#b154

#49d4

    Lb154_robot_ai_update:

#b154

#49d4

3

21

    fd 7e 0a

        ld a, (iy + ROBOT_STRUCT_CONTROL)

#b157

#49d7

2

8

    fe 01

        cp ROBOT_CONTROL_PLAYER_LANDED

#b159

#49d9

1

12/6

    c8

        ret z  ; If the player has landed on top of the robot, do not update

#b15a

#49da

#b15a

#49da

1

5

    07

        rlca

#b15b

#49db

2

8

    e6 01

        and 1

#b15d

#49dd

3

14

    32 51 fd

        ld (Lfd51_current_robot_player_or_enemy), a

#b160

#49e0

3

25

    fd 35 0f

        dec (iy + ROBOT_STRICT_CYCLES_TO_NEXT_UPDATE)

#b163

#49e3

1

12/6

    c0

        ret nz  ; if we do not yet need to update this robot, skip

#b164

#49e4

#b164

#49e4

3

21

    fd 6e 00

        ld l, (iy + ROBOT_STRUCT_MAP_PTR)

#b167

#49e7

3

21

    fd 66 01

        ld h, (iy + ROBOT_STRUCT_MAP_PTR + 1)

#b16a

#49ea

2

17

    cb b6

        res 6, (hl)  ; remove the mark of this robot in the map for now

#b16c

#49ec

1

12

    e5

        push hl

#b16d

#49ed

3

21

    fd 6e 02

            ld l, (iy + ROBOT_STRUCT_X)

#b170

#49f0

3

21

    fd 66 03

            ld h, (iy + ROBOT_STRUCT_X + 1)

#b173

#49f3

3

21

    fd 4e 04

            ld c, (iy + ROBOT_STRUCT_Y)

#b176

#49f6

3

21

    fd 7e 0a

            ld a, (iy + ROBOT_STRUCT_CONTROL)

#b179

#49f9

1

5

    07

            rlca

#b17a

#49fa

2

8

    e6 01

            and 1

#b17c

#49fc

1

5

    47

            ld b, a  ; potential optimization: this was already computed above.

#b17d

#49fd

3

18

    cd 5a d6

            call Ld65a_flip_2x2_radar_area

#b180

#4a00

1

11

    e1

        pop hl

#b181

#4a01

3

18

    cd 13 b5

        call Lb513_get_robot_movement_possibilities

#b184

#4a04

3

21

    fd 7e 0a

        ld a, (iy + ROBOT_STRUCT_CONTROL)

#b187

#4a07

2

8

    fe 02

        cp ROBOT_CONTROL_DIRECT_CONTROL

#b189

#4a09

3

11

    ca 50 b4

        jp z, Lb450_robot_control_direct_control

#b18c

#4a0c

1

12

    c5

        push bc

#b18d

#4a0d

3

18

    cd 26 b6

            call Lb626_check_directions_with_enemy_robots

#b190

#4a10

1

11

    c1

        pop bc

#b191

#4a11

1

5

    7b

        ld a, e

#b192

#4a12

1

5

    b7

        or a

#b193

#4a13

2

13/8

    28 54

        jr z, Lb1e9_no_enemy_robots_in_sight

#b195

#4a15

#b195

#4a15

3

21

    fd a6 08

        and (iy + ROBOT_STRUCT_DIRECTION)

#b198

#4a18

2

13/8

    28 3d

        jr z, Lb1d7_no_enemy_robots_in_the_current_direction

#b19a

#4a1a

        ; If we are here, there is an enemy robot just ahead

#b19a

#4a1a

1

5

    a1

        and c

#b19b

#4a1b

3

21

    fd 77 05

        ld (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION), a

#b19e

#4a1e

2

17

    dd e5

        push ix

#b1a0

#4a20

2

17

    fd e5

        push iy

#b1a2

#4a22

2

17

    fd e5

            push iy

#b1a4

#4a24

2

16

    dd e1

            pop ix

#b1a6

#4a26

3

18

    cd b8 b6

            call Lb6b8_find_new_bullet_ptr

#b1a9

#4a29

2

13/8

    20 22

            jr nz, Lb1cd_do_not_fire

#b1ab

#4a2b

3

18

    cd 58 d3

            call Ld358_random  ; pick one of our weapons at random

#b1ae

#4a2e

2

8

    e6 38

            and #38  ; bits corresponding to weapons (cannon, missiles, phaser)

#b1b0

#4a30

3

21

    dd a6 07

            and (ix + ROBOT_STRUCT_PIECES)

#b1b3

#4a33

2

13/8

    28 18

            jr z, Lb1cd_do_not_fire

#b1b5

#4a35

            ; Get the index of the lowest bit in "a" that is 1, corresponding to a weapon piece:

#b1b5

#4a35

2

8

    0e 06

            ld c, 6

#b1b7

#4a37

    Lb1b7:

#b1b7

#4a37

1

5

    0d

            dec c

#b1b8

#4a38

1

5

    07

            rlca

#b1b9

#4a39

2

13/8

    30 fc

            jr nc, Lb1b7

#b1bb

#4a3b

1

5

    79

            ld a, c

#b1bc

#4a3c

3

18

    cd d6 b6

            call Lb6d6_weapon_fire

#b1bf

#4a3f

2

16

    fd e1

        pop iy

#b1c1

#4a41

2

16

    dd e1

        pop ix

#b1c3

#4a43

4

21

    fd 36 05 00

        ld (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION), 0

#b1c7

#4a47

4

21

    fd 36 06 01

        ld (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), 1

#b1cb

#4a4b

2

13

    18 40

        jr Lb20d_move_robot

#b1cd

#4a4d

    Lb1cd_do_not_fire:

#b1cd

#4a4d

2

16

    fd e1

        pop iy

#b1cf

#4a4f

2

16

    dd e1

        pop ix

#b1d1

#4a51

4

21

    fd 36 06 01

        ld (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), 1

#b1d5

#4a55

2

13

    18 36

        jr Lb20d_move_robot

#b1d7

#4a57

    Lb1d7_no_enemy_robots_in_the_current_direction:

#b1d7

#4a57

1

5

    4b

        ld c, e

#b1d8

#4a58

1

5

    41

        ld b, c

#b1d9

#4a59

3

18

    cd 05 b5

        call Lb505_check_number_of_directions_is_one

#b1dc

#4a5c

3

18/11

    c4 3e b3

        call nz, Lb33e_pick_direction_at_random

#b1df

#4a5f

3

21

    fd 71 05

        ld (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION), c

#b1e2

#4a62

4

21

    fd 36 06 02

        ld (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), 2

#b1e6

#4a66

3

11

    c3 0d b2

        jp Lb20d_move_robot

#b1e9

#4a69

    Lb1e9_no_enemy_robots_in_sight:

#b1e9

#4a69

3

25

    fd 35 06

        dec (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING)

#b1ec

#4a6c

3

11

    fa f5 b1

        jp m, Lb1f5_move_in_a_new_direction

#b1ef

#4a6f

3

21

    fd 7e 05

        ld a, (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION)

#b1f2

#4a72

1

5

    a1

        and c

#b1f3

#4a73

2

13/8

    20 18

        jr nz, Lb20d_move_robot

#b1f5

#4a75

    Lb1f5_move_in_a_new_direction:

#b1f5

#4a75

        ; pick a random number of steps:

#b1f5

#4a75

3

18

    cd 58 d3

        call Ld358_random

#b1f8

#4a78

2

8

    e6 03

        and 3

#b1fa

#4a7a

2

8

    c6 03

        add a, 3

#b1fc

#4a7c

3

21

    fd 77 06

        ld (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), a

#b1ff

#4a7f

3

18

    cd 05 b5

        call Lb505_check_number_of_directions_is_one

#b202

#4a82

3

18/11

    d4 22 b2

        call nc, Lb222_choose_direction_to_move

#b205

#4a85

3

21

    fd 7e 01

        ld a, (iy + ROBOT_STRUCT_MAP_PTR + 1)

#b208

#4a88

1

5

    b7

        or a

#b209

#4a89

1

12/6

    c8

        ret z

#b20a

#4a8a

3

21

    fd 71 05

        ld (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION), c

#b20d

#4a8d

#b20d

#4a8d

    Lb20d_move_robot:

#b20d

#4a8d

3

21

    fd 7e 05

        ld a, (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION)

#b210

#4a90

3

21

    fd 6e 02

        ld l, (iy + ROBOT_STRUCT_X)

#b213

#4a93

3

21

    fd 66 03

        ld h, (iy + ROBOT_STRUCT_X + 1)

#b216

#4a96

3

21

    fd 46 04

        ld b, (iy + ROBOT_STRUCT_Y)

#b219

#4a99

3

18

    cd 71 b4

        call Lb471_move_robot_one_step_in_desired_direction

#b21c

#4a9c

3

18

    cd f3 b5

        call Lb5f3_determine_speed_based_on_terrain

#b21f

#4a9f

3

11

    c3 7c cc

        jp Lcc7c_set_robot_position

#b222

#4aa2

#b222

#4aa2

#b222

#4aa2

    ; --------------------------------

#b222

#4aa2

    ; Chooses a direction for a robot to move to, considering the orders and target.

#b222

#4aa2

    ; Input:

#b222

#4aa2

    ; - iy: robot ptr.

#b222

#4aa2

    ; - c: one-hot representation of the directions we can to move the robot in.

#b222

#4aa2

    ; Output:

#b222

#4aa2

    ; - c: direction to move.

#b222

#4aa2

    Lb222_choose_direction_to_move:

#b222

#4aa2

1

5

    41

        ld b, c

#b223

#4aa3

3

21

    fd 7e 0b

        ld a, (iy + ROBOT_STRUCT_ORDERS)

#b226

#4aa6

1

5

    b7

        or a

#b227

#4aa7

2

13/8

    20 02

        jr nz, Lb22b_choose_direction_to_move_continue

#b229

#4aa9

1

5

    4f

        ld c, a  ; if orders are "stop and defend", just set direction = 0

#b22a

#4aaa

1

11

    c9

        ret

#b22b

#4aab

#b22b

#4aab

    Lb22b_choose_direction_to_move_continue:

#b22b

#4aab

2

8

    fe 03

        cp ROBOT_ORDERS_DESTROY_ENEMY_ROBOTS

#b22d

#4aad

3

11

    da 26 b3

        jp c, Lb326_choose_direction_orders_with_possible_directions

#b230

#4ab0

2

13/8

    20 57

        jr nz, Lb289_choose_direction_orders_with_building_targets

#b232

#4ab2

#b232

#4ab2

        ; Destroy enemy robots orders:

#b232

#4ab2

3

21

    fd 7e 0e

        ld a, (iy + ROBOT_STRUCT_ORDERS_ARGUMENT)

#b235

#4ab5

1

5

    b7

        or a

#b236

#4ab6

3

11

    fa 58 b2

        jp m, Lb258_find_new_robot_target

#b239

#4ab9

3

18

    cd f9 b3

        call Lb3f9_find_orders_target_robot_ptr

#b23c

#4abc

1

7

    23

        inc hl

#b23d

#4abd

1

8

    7e

        ld a, (hl)

#b23e

#4abe

1

5

    b7

        or a

#b23f

#4abf

2

13/8

    28 17

        jr z, Lb258_find_new_robot_target  ; if our current target was already destroyed, pick a new one

#b241

#4ac1

1

7

    23

        inc hl

#b242

#4ac2

1

8

    7e

        ld a, (hl)

#b243

#4ac3

1

7

    23

        inc hl

#b244

#4ac4

1

8

    66

        ld h, (hl)

#b245

#4ac5

1

5

    6f

        ld l, a  ; hl now is target robot "x"

#b246

#4ac6

3

21

    fd 5e 02

        ld e, (iy + ROBOT_STRUCT_X)

#b249

#4ac9

3

21

    fd 56 03

        ld d, (iy + ROBOT_STRUCT_X + 1)

#b24c

#4acc

3

18

    cd ca b3

        call Lb3ca_distance_from_hl_to_de

#b24f

#4acf

1

5

    7c

        ld a, h

#b250

#4ad0

1

5

    b7

        or a

#b251

#4ad1

2

13/8

    20 05

        jr nz, Lb258_find_new_robot_target  ; If robot target is too far, pick a new one.

#b253

#4ad3

1

5

    7d

        ld a, l

#b254

#4ad4

2

8

    fe 32

        cp 50

#b256

#4ad6

2

13/8

    38 15

        jr c, Lb26d_choose_direction_to_target_robot  ; If robot target is too far, pick a new one.

#b258

#4ad8

    Lb258_find_new_robot_target:

#b258

#4ad8

3

21

    fd 6e 02

        ld l, (iy + ROBOT_STRUCT_X)

#b25b

#4adb

3

21

    fd 66 03

        ld h, (iy + ROBOT_STRUCT_X + 1)

#b25e

#4ade

4

21

    fd 36 0e ff

        ld (iy + ROBOT_STRUCT_ORDERS_ARGUMENT), #ff

#b262

#4ae2

1

12

    c5

        push bc

#b263

#4ae3

3

18

    cd 1d b4

            call Lb41d_find_nearest_opponent_robot

#b266

#4ae6

1

11

    c1

        pop bc

#b267

#4ae7

3

21

    fd 72 0e

        ld (iy + ROBOT_STRUCT_ORDERS_ARGUMENT), d

#b26a

#4aea

3

11

    ca 3e b3

        jp z, Lb33e_pick_direction_at_random  ; if no nearest robot, pick a direction at random.

#b26d

#4aed

#b26d

#4aed

    Lb26d_choose_direction_to_target_robot:

#b26d

#4aed

3

18

    cd f9 b3

        call Lb3f9_find_orders_target_robot_ptr

#b270

#4af0

1

7

    23

        inc hl

#b271

#4af1

1

7

    23

        inc hl

#b272

#4af2

1

8

    5e

        ld e, (hl)

#b273

#4af3

1

7

    23

        inc hl

#b274

#4af4

1

8

    56

        ld d, (hl)  ; "de" now has the target robot "x"

#b275

#4af5

1

7

    23

        inc hl

#b276

#4af6

3

21

    fd 7e 04

        ld a, (iy + ROBOT_STRUCT_Y)

#b279

#4af9

1

8

    96

        sub (hl)

#b27a

#4afa

1

5

    47

        ld b, a  ; "b" now has "y" - "target robot y"

#b27b

#4afb

3

21

    fd 6e 02

        ld l, (iy + ROBOT_STRUCT_X)

#b27e

#4afe

3

21

    fd 66 03

        ld h, (iy + ROBOT_STRUCT_X + 1)

#b281

#4b01

1

5

    af

        xor a

#b282

#4b02

2

17

    ed 52

        sbc hl, de  ; "hl" now has "x" - "target robot x"

#b284

#4b04

1

5

    57

        ld d, a  ; "d" = 0 to indicate same x ("Lb2d5_choose_direction_to_target_coordinates" will

#b285

#4b05

                 ; overwrite if they are not).

#b285

#4b05

2

13/8

    28 55

        jr z, Lb2dc_choose_direction_to_target_coordinates_x_alread_considered

#b287

#4b07

2

13

    18 4c

        jr Lb2d5_choose_direction_to_target_coordinates

#b289

#4b09

#b289

#4b09

    Lb289_choose_direction_orders_with_building_targets:

#b289

#4b09

        ; If we are here, orders are to capture/destroy some building.

#b289

#4b09

3

18

    cd d5 b3

        call Lb3d5_prepare_robot_order_building_target_search

#b28c

#4b0c

3

21

    fd 7e 0e

        ld a, (iy + ROBOT_STRUCT_ORDERS_ARGUMENT)

#b28f

#4b0f

1

5

    47

        ld b, a

#b290

#4b10

1

5

    87

        add a, a

#b291

#4b11

1

5

    87

        add a, a

#b292

#4b12

1

5

    80

        add a, b  ; a *= BUILDING_STRUCT_SIZE

#b293

#4b13

3

18

    cd 51 d3

        call Ld351_add_hl_a  ; hl has the pointer to the target

#b296

#4b16

1

8

    7e

        ld a, (hl)

#b297

#4b17

2

8

    e6 e0

        and #e0  ; keep just the flags

#b299

#4b19

1

5

    bb

        cp e  ; see if the flags match the orders target

#b29a

#4b1a

2

13/8

    28 1f

        jr z, Lb2bb_choose_direction_to_target_building

#b29c

#4b1c

        ; Pick a new target building:

#b29c

#4b1c

3

21

    fd 7e 0b

        ld a, (iy + ROBOT_STRUCT_ORDERS)

#b29f

#4b1f

1

12

    c5

        push bc

#b2a0

#4b20

3

21

    fd 6e 02

            ld l, (iy + ROBOT_STRUCT_X)

#b2a3

#4b23

3

21

    fd 66 03

            ld h, (iy + ROBOT_STRUCT_X + 1)

#b2a6

#4b26

3

18

    cd 4d b3

            call Lb34d_find_capture_or_destroy_target

#b2a9

#4b29

1

11

    c1

        pop bc

#b2aa

#4b2a

2

13/8

    20 0c

        jr nz, Lb2b8_target_found

#b2ac

#4b2c

        ; We could not find any target:

#b2ac

#4b2c

2

8

    0e 00

        ld c, 0

#b2ae

#4b2e

4

22

    fd cb 0a 7e

        bit 7, (iy + ROBOT_STRUCT_CONTROL)

#b2b2

#4b32

1

12/6

    c8

        ret z

#b2b3

#4b33

        ; if it's an enemy AI controlled robot, switch to targeting player robots:

#b2b3

#4b33

4

21

    fd 36 0b 03

        ld (iy + ROBOT_STRUCT_ORDERS), ROBOT_ORDERS_DESTROY_ENEMY_ROBOTS

#b2b7

#4b37

1

11

    c9

        ret

#b2b8

#4b38

#b2b8

#4b38

    Lb2b8_target_found:

#b2b8

#4b38

3

21

    fd 72 0e

        ld (iy + ROBOT_STRUCT_ORDERS_ARGUMENT), d

#b2bb

#4b3b

    Lb2bb_choose_direction_to_target_building:

#b2bb

#4b3b

        ; Calculate the relative target coordinates:

#b2bb

#4b3b

1

7

    2b

        dec hl

#b2bc

#4b3c

3

21

    fd 7e 04

        ld a, (iy + ROBOT_STRUCT_Y)

#b2bf

#4b3f

1

8

    96

        sub (hl)

#b2c0

#4b40

1

5

    47

        ld b, a  ; "b" now has "y" - "target robot y"

#b2c1

#4b41

1

7

    2b

        dec hl

#b2c2

#4b42

1

8

    56

        ld d, (hl)

#b2c3

#4b43

1

7

    2b

        dec hl

#b2c4

#4b44

1

8

    5e

        ld e, (hl)

#b2c5

#4b45

3

21

    fd 6e 02

        ld l, (iy + ROBOT_STRUCT_X)

#b2c8

#4b48

3

21

    fd 66 03

        ld h, (iy + ROBOT_STRUCT_X + 1)

#b2cb

#4b4b

1

5

    af

        xor a

#b2cc

#4b4c

2

17

    ed 52

        sbc hl, de  ; "hl" now has "x" - "target robot x"

#b2ce

#4b4e

1

5

    57

        ld d, a  ; "d" = 0 to indicate same x ("Lb2d5_choose_direction_to_target_coordinates" will

#b2cf

#4b4f

                 ; overwrite if they are not).

#b2cf

#4b4f

2

13/8

    28 0b

        jr z, Lb2dc_choose_direction_to_target_coordinates_x_alread_considered

#b2d1

#4b51

1

5

    78

        ld a, b

#b2d2

#4b52

2

8

    d6 03

        sub 3

#b2d4

#4b54

1

5

    47

        ld b, a

#b2d5

#4b55

    Lb2d5_choose_direction_to_target_coordinates:

#b2d5

#4b55

        ; At this point we have the relative position of the target to the robot in "hl", "b"

#b2d5

#4b55

1

5

    7c

        ld a, h

#b2d6

#4b56

1

5

    0f

        rrca

#b2d7

#4b57

2

8

    e6 03

        and #03  ; a = (h/2) mod 4

#b2d9

#4b59

2

8

    ee 02

        xor 2  ; flip the second bit

#b2db

#4b5b

1

5

    57

        ld d, a  ; d = 1 if difference in "x" is negative, d = 2 if difference is positive

#b2dc

#4b5c

    Lb2dc_choose_direction_to_target_coordinates_x_alread_considered:

#b2dc

#4b5c

1

5

    78

        ld a, b

#b2dd

#4b5d

1

5

    b7

        or a

#b2de

#4b5e

2

13/8

    28 08

        jr z, Lb2e8_target_directions_calculated

#b2e0

#4b60

        ; different y:

#b2e0

#4b60

        ; accumulate in "d" the good directions to go toward the target:

#b2e0

#4b60

1

5

    0f

        rrca

#b2e1

#4b61

1

5

    0f

        rrca

#b2e2

#4b62

2

8

    e6 0c

        and #0c

#b2e4

#4b64

2

8

    ee 08

        xor 8

#b2e6

#4b66

1

5

    b2

        or d

#b2e7

#4b67

1

5

    57

        ld d, a  ; d now has "1"s in the up/down directions pointing toward the target

#b2e8

#4b68

    Lb2e8_target_directions_calculated:

#b2e8

#4b68

1

5

    7a

        ld a, d

#b2e9

#4b69

1

5

    b7

        or a

#b2ea

#4b6a

2

13/8

    20 1a

        jr nz, Lb306_not_at_target

#b2ec

#4b6c

        ; We are at the target position:

#b2ec

#4b6c

1

5

    4f

        ld c, a

#b2ed

#4b6d

3

21

    fd 7e 0b

        ld a, (iy + ROBOT_STRUCT_ORDERS)

#b2f0

#4b70

2

8

    fe 04

        cp ROBOT_ORDERS_DESTROY_ENEMY_FACTORIES

#b2f2

#4b72

2

13/8

    38 05

        jr c, Lb2f9_inconsistent_orders

#b2f4

#4b74

2

8

    fe 06

        cp ROBOT_ORDERS_CAPTURE_NEUTRAL_FACTORIES

#b2f6

#4b76

3

11

    da 9f b9

        jp c, Lb99f_fire_nuclear_bomb

#b2f9

#4b79

    Lb2f9_inconsistent_orders:

#b2f9

#4b79

        ; If we reached here, something went wrong (we have orders ROBOT_ORDERS_DESTROY_ENEMY_ROBOTS,

#b2f9

#4b79

        ; but are exactly on target, which is weird, so, just keep moving)

#b2f9

#4b79

3

21

    fd 7e 08

        ld a, (iy + ROBOT_STRUCT_DIRECTION)

#b2fc

#4b7c

2

8

    fe 04

        cp 4

#b2fe

#4b7e

1

12/6

    c8

        ret z

#b2ff

#4b7f

2

8

    0e 04

        ld c, 4  ; desired direction is down, and go until collision, then reconsider.

#b301

#4b81

4

21

    fd 36 06 ff

        ld (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), #ff

#b305

#4b85

1

11

    c9

        ret

#b306

#4b86

    Lb306_not_at_target:

#b306

#4b86

        ; get the absolute difference of the "x" difference:

#b306

#4b86

1

5

    7d

        ld a, l

#b307

#4b87

1

5

    b7

        or a

#b308

#4b88

3

11

    f2 0e b3

        jp p, Lb30e_x_diff_positive

#b30b

#4b8b

2

10

    ed 44

        neg

#b30d

#4b8d

1

5

    6f

        ld l, a

#b30e

#4b8e

    Lb30e_x_diff_positive:

#b30e

#4b8e

2

8

    fe 08

        cp 8

#b310

#4b90

1

5

    41

        ld b, c

#b311

#4b91

1

5

    7a

        ld a, d

#b312

#4b92

2

13/8

    30 12

        jr nc, Lb326_choose_direction_orders_with_possible_directions  ; if target is further than 8

#b314

#4b94

                                                                       ; positions away follow the

#b314

#4b94

                                                                       ; target directions.

#b314

#4b94

        ; If we are closer than 8 cells (in "x") to the target, we will move at random until reaching

#b314

#4b94

        ; it:

#b314

#4b94

1

5

    a1

        and c

#b315

#4b95

2

13/8

    28 27

        jr z, Lb33e_pick_direction_at_random  ; if we have no good directions, pick one at random

#b317

#4b97

1

5

    47

        ld b, a

#b318

#4b98

2

8

    e6 03

        and #03

#b31a

#4b9a

2

13/8

    28 22

        jr z, Lb33e_pick_direction_at_random  ; If we cannot go left/right, pick a direction at random.

#b31c

#4b9c

1

5

    7d

        ld a, l

#b31d

#4b9d

1

5

    b7

        or a

#b31e

#4b9e

2

13/8

    28 1e

        jr z, Lb33e_pick_direction_at_random  ; if we are at the same "x", pick a direction at random

#b320

#4ba0

1

5

    3d

        dec a  ; set the number of steps to keep walking to the distance to the target in "x" - 1

#b321

#4ba1

3

21

    fd 77 06

        ld (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), a

#b324

#4ba4

2

13

    18 18

        jr Lb33e_pick_direction_at_random

#b326

#4ba6

#b326

#4ba6

    Lb326_choose_direction_orders_with_possible_directions:

#b326

#4ba6

        ; If we are here is that "a" has the good directions to move in.

#b326

#4ba6

2

8

    e6 03

        and #03

#b328

#4ba8

1

5

    57

        ld d, a

#b329

#4ba9

2

8

    ee fc

        xor #fc  ; here we reverse the up/down directions, to try something different if we fail to

#b32b

#4bab

                 ; pick a direction.

#b32b

#4bab

1

5

    5f

        ld e, a

#b32c

#4bac

1

5

    79

        ld a, c  ; c has the possible directions we can move in

#b32d

#4bad

1

5

    a2

        and d  ; if stop&defend, a = 0, if it's advance/retreat: a direction compatible with it if

#b32e

#4bae

               ; available.

#b32e

#4bae

2

13/8

    28 0e

        jr z, Lb33e_pick_direction_at_random  ; if no direction compatible with orders, pick one at

#b330

#4bb0

                                              ; random.

#b330

#4bb0

        ; Otherwise, try twice to pick a direction among the ones that are compatible:

#b330

#4bb0

1

5

    4a

        ld c, d

#b331

#4bb1

3

18

    cd 58 d3

        call Ld358_random

#b334

#4bb4

1

5

    a2

        and d

#b335

#4bb5

1

12/6

    c0

        ret nz  ; first attempt

#b336

#4bb6

3

18

    cd 58 d3

        call Ld358_random

#b339

#4bb9

1

5

    a2

        and d

#b33a

#4bba

1

12/6

    c0

        ret nz  ; second attempt

#b33b

#4bbb

1

5

    78

        ld a, b  ; b still has the available directions of movement

#b33c

#4bbc

1

5

    a3

        and e

#b33d

#4bbd

1

5

    47

        ld b, a  ; now b has compatible directions (with up/down flipped). So, we pick one at random

#b33e

#4bbe

                 ; from those:

#b33e

#4bbe

#b33e

#4bbe

    Lb33e_pick_direction_at_random:

#b33e

#4bbe

1

5

    48

        ld c, b

#b33f

#4bbf

        ; keep generating random numbers, and masking with the possible directions,

#b33f

#4bbf

        ; until we get just 1 direction, and use it:

#b33f

#4bbf

    Lb33f_pick_direction_at_random_loop:

#b33f

#4bbf

3

18

    cd 58 d3

        call Ld358_random

#b342

#4bc2

1

5

    a1

        and c

#b343

#4bc3

1

5

    4f

        ld c, a

#b344

#4bc4

3

18

    cd 05 b5

        call Lb505_check_number_of_directions_is_one

#b347

#4bc7

1

12/6

    c8

        ret z

#b348

#4bc8

2

13/8

    30 f5

        jr nc, Lb33f_pick_direction_at_random_loop

#b34a

#4bca

1

5

    48

        ld c, b

#b34b

#4bcb

2

13

    18 f2

        jr Lb33f_pick_direction_at_random_loop

#b34d

#4bcd

#b34d

#4bcd

#b34d

#4bcd

    ; --------------------------------

#b34d

#4bcd

    ; Finds the target for a capture or destroy order. This can be

#b34d

#4bcd

    ; the index of a robot, or the index of a building.

#b34d

#4bcd

    ; Input:

#b34d

#4bcd

    ; - a: orders

#b34d

#4bcd

    ; Output:

#b34d

#4bcd

    ; - d: target.

#b34d

#4bcd

    ; - z: no target found.

#b34d

#4bcd

    ; - nz: target found.

#b34d

#4bcd

    Lb34d_find_capture_or_destroy_target:

#b34d

#4bcd

2

8

    fe 03

        cp ROBOT_ORDERS_DESTROY_ENEMY_ROBOTS

#b34f

#4bcf

3

11

    ca 1d b4

        jp z, Lb41d_find_nearest_opponent_robot

#b352

#4bd2

1

12

    f5

        push af

#b353

#4bd3

1

5

    08

            ex af, af'

#b354

#4bd4

1

11

    f1

        pop af

#b355

#4bd5

3

18

    cd 11 b4

        call Lb411_prepare_nearest_robot_or_building_search_registers

#b358

#4bd8

3

18

    cd d5 b3

        call Lb3d5_prepare_robot_order_building_target_search

#b35b

#4bdb

    Lb35b_building_loop:

#b35b

#4bdb

1

8

    7e

        ld a, (hl)

#b35c

#4bdc

2

8

    e6 e0

        and #e0

#b35e

#4bde

1

5

    bb

        cp e  ; check if they match the order target flags

#b35f

#4bdf

3

18/11

    cc 6c b3

        call z, Lb36c_check_if_building_is_available_and_nearest_than_current_nearest

#b362

#4be2

        ; next building:

#b362

#4be2

1

5

    7d

        ld a, l

#b363

#4be3

2

8

    c6 05

        add a, BUILDING_STRUCT_SIZE

#b365

#4be5

1

5

    6f

        ld l, a

#b366

#4be6

1

5

    0c

        inc c

#b367

#4be7

2

14/9

    10 f2

        djnz Lb35b_building_loop

#b369

#4be9

1

5

    7a

        ld a, d  ; d has the nearest building that was available as a target.

#b36a

#4bea

1

5

    3c

        inc a  ; check if we found a target (d == #ff means no target found).

#b36b

#4beb

1

11

    c9

        ret

#b36c

#4bec

#b36c

#4bec

#b36c

#4bec

    ; --------------------------------

#b36c

#4bec

    ; Given a building (index "c"), checks to make sure no other robot with the same

#b36c

#4bec

    ; orders as the current robot has that building as its target already. Then, if

#b36c

#4bec

    ; this is not the case, checks to see if this is closer than the previous target

#b36c

#4bec

    ; we had found. IF it is, set this building as the current target.

#b36c

#4bec

    ; Input:

#b36c

#4bec

    ; - a': orders

#b36c

#4bec

    ; - c: current building index

#b36c

#4bec

    Lb36c_check_if_building_is_available_and_nearest_than_current_nearest:

#b36c

#4bec

2

17

    fd e5

        push iy

#b36e

#4bee

1

12

    c5

        push bc

#b36f

#4bef

1

12

    d5

        push de

#b370

#4bf0

1

5

    08

                ex af, af'

#b371

#4bf1

1

5

    5f

                    ld e, a  ; retrieve the orders

#b372

#4bf2

1

5

    08

                ex af, af'

#b373

#4bf3

            ; Check if there is already another robot with the same orders, and that

#b373

#4bf3

            ; already has this target:

#b373

#4bf3

            ; Determine if we are searching over player or enemy robots:

#b373

#4bf3

4

16

    fd 21 00 da

            ld iy, Lda00_player1_robots

#b377

#4bf7

3

14

    3a 51 fd

            ld a, (Lfd51_current_robot_player_or_enemy)

#b37a

#4bfa

1

5

    b7

            or a

#b37b

#4bfb

2

13/8

    28 04

            jr z, Lb381_target_robots_ptr_set

#b37d

#4bfd

4

16

    fd 21 80 db

            ld iy, Ldb80_player2_robots

#b381

#4c01

    Lb381_target_robots_ptr_set:

#b381

#4c01

2

8

    06 18

            ld b, MAX_ROBOTS_PER_PLAYER

#b383

#4c03

    Lb383:

#b383

#4c03

3

21

    fd 7e 01

            ld a, (iy + 1)

#b386

#4c06

1

5

    b7

            or a

#b387

#4c07

2

13/8

    28 0c

            jr z, Lb395_next_robot

#b389

#4c09

3

21

    fd 7e 0b

            ld a, (iy + ROBOT_STRUCT_ORDERS)

#b38c

#4c0c

1

5

    bb

            cp e  ; Check if robot has the same orders

#b38d

#4c0d

2

13/8

    20 06

            jr nz, Lb395_next_robot

#b38f

#4c0f

3

21

    fd 7e 0e

            ld a, (iy + ROBOT_STRUCT_ORDERS_ARGUMENT)

#b392

#4c12

1

5

    b9

            cp c  ; check if the other robot already has this building as the target

#b393

#4c13

2

13/8

    28 19

            jr z, Lb3ae_skip_building

#b395

#4c15

    Lb395_next_robot:

#b395

#4c15

1

12

    d5

            push de

#b396

#4c16

3

11

    11 10 00

                ld de, ROBOT_STRUCT_SIZE

#b399

#4c19

2

17

    fd 19

                add iy, de

#b39b

#4c1b

1

11

    d1

            pop de

#b39c

#4c1c

2

14/9

    10 e5

            djnz Lb383

#b39e

#4c1e

1

11

    d1

        pop de

#b39f

#4c1f

1

11

    c1

        pop bc

#b3a0

#4c20

2

16

    fd e1

        pop iy

#b3a2

#4c22

        ; If we reached this point, it means that there is no other robot that has

#b3a2

#4c22

        ; this building as its target. See if it's closer than the current closest:

#b3a2

#4c22

1

12

    e5

        push hl

#b3a3

#4c23

1

7

    2b

            dec hl

#b3a4

#4c24

1

7

    2b

            dec hl

#b3a5

#4c25

1

8

    7e

            ld a, (hl)

#b3a6

#4c26

1

7

    2b

            dec hl

#b3a7

#4c27

1

8

    6e

            ld l, (hl)

#b3a8

#4c28

1

5

    67

            ld h, a

#b3a9

#4c29

3

18

    cd b3 b3

            call Lb3b3_check_if_nearer_than_current_nearest

#b3ac

#4c2c

1

11

    e1

        pop hl

#b3ad

#4c2d

1

11

    c9

        ret

#b3ae

#4c2e

    Lb3ae_skip_building:

#b3ae

#4c2e

1

11

    d1

        pop de

#b3af

#4c2f

1

11

    c1

        pop bc

#b3b0

#4c30

2

16

    fd e1

        pop iy

#b3b2

#4c32

1

11

    c9

        ret

#b3b3

#4c33

#b3b3

#4c33

#b3b3

#4c33

    ; --------------------------------

#b3b3

#4c33

    ; Check if the coordinate "hl" (x) is nearer than the current robot

#b3b3

#4c33

    ; believed to be the nearest to the reference robot (only considering "x").

#b3b3

#4c33

    ; Input:

#b3b3

#4c33

    ; - hl: x coordinate to check

#b3b3

#4c33

    Lb3b3_check_if_nearer_than_current_nearest:

#b3b3

#4c33

1

12

    e5

        push hl

#b3b4

#4c34

1

5

    d9

        exx

#b3b5

#4c35

1

11

    e1

            pop hl

#b3b6

#4c36

3

18

    cd ca b3

            call Lb3ca_distance_from_hl_to_de  ; distance from "hl" to reference robot

#b3b9

#4c39

1

5

    7c

            ld a, h

#b3ba

#4c3a

1

5

    b8

            cp b

#b3bb

#4c3b

2

13/8

    38 06

            jr c, Lb3c3_new_closest

#b3bd

#4c3d

2

13/8

    20 09

            jr nz, Lb3c8

#b3bf

#4c3f

1

5

    7d

            ld a, l

#b3c0

#4c40

1

5

    b9

            cp c

#b3c1

#4c41

2

13/8

    30 05

            jr nc, Lb3c8

#b3c3

#4c43

    Lb3c3_new_closest:

#b3c3

#4c43

1

5

    44

            ld b, h  ; update the "closest distance"

#b3c4

#4c44

1

5

    4d

            ld c, l

#b3c5

#4c45

1

5

    d9

        exx

#b3c6

#4c46

1

5

    51

        ld d, c  ; update the index of the closest robot

#b3c7

#4c47

1

11

    c9

        ret

#b3c8

#4c48

    Lb3c8:

#b3c8

#4c48

1

5

    d9

        exx

#b3c9

#4c49

1

11

    c9

        ret

#b3ca

#4c4a

#b3ca

#4c4a

#b3ca

#4c4a

    ; --------------------------------

#b3ca

#4c4a

    ; Returns the absolute value of |hl - de|.

#b3ca

#4c4a

    Lb3ca_distance_from_hl_to_de:

#b3ca

#4c4a

1

5

    af

        xor a

#b3cb

#4c4b

2

17

    ed 52

        sbc hl, de

#b3cd

#4c4d

1

12/6

    f0

        ret p

#b3ce

#4c4e

1

5

    95

        sub l

#b3cf

#4c4f

1

5

    6f

        ld l, a

#b3d0

#4c50

2

8

    3e 00

        ld a, 0

#b3d2

#4c52

1

5

    9c

        sbc a, h

#b3d3

#4c53

1

5

    67

        ld h, a

#b3d4

#4c54

1

11

    c9

        ret

#b3d5

#4c55

#b3d5

#4c55

#b3d5

#4c55

    ; --------------------------------

#b3d5

#4c55

    ; Given the orders of the current robot, prepares the registers to look for a potential

#b3d5

#4c55

    ; target.

#b3d5

#4c55

    ; Input:

#b3d5

#4c55

    ; - a: robot orders

#b3d5

#4c55

    ; Output:

#b3d5

#4c55

    ; - hl: ptr to factories or warbases

#b3d5

#4c55

    ; - b: # buildings to search

#b3d5

#4c55

    ; - e: target flags (whether we are looking for friendly, enemy or neutral buildings).

#b3d5

#4c55

    Lb3d5_prepare_robot_order_building_target_search:

#b3d5

#4c55

3

11

    21 87 fd

        ld hl, Lfd84_factories + BUILDING_STRUCT_TYPE

#b3d8

#4c58

2

8

    06 18

        ld b, N_FACTORIES

#b3da

#4c5a

2

8

    fe 05

        cp ROBOT_ORDERS_DESTROY_ENEMY_WARBASES

#b3dc

#4c5c

2

13/8

    28 04

        jr z, Lb3e2_look_for_a_warbase

#b3de

#4c5e

2

8

    fe 08

        cp ROBOT_ORDERS_CAPTURE_ENEMY_WARBASES

#b3e0

#4c60

2

13/8

    20 05

        jr nz, Lb3e7_continue

#b3e2

#4c62

    Lb3e2_look_for_a_warbase:

#b3e2

#4c62

3

11

    21 73 fd

        ld hl, Lfd70_warbases + BUILDING_STRUCT_TYPE

#b3e5

#4c65

2

8

    06 04

        ld b, N_WARBASES

#b3e7

#4c67

    Lb3e7_continue:

#b3e7

#4c67

2

8

    1e 20

        ld e, #20  ; bit 5 (indicates enemy)

#b3e9

#4c69

1

12

    f5

        push af

#b3ea

#4c6a

3

14

    3a 51 fd

            ld a, (Lfd51_current_robot_player_or_enemy)

#b3ed

#4c6d

1

5

    b7

            or a

#b3ee

#4c6e

2

13/8

    28 02

            jr z, Lb3f2_player

#b3f0

#4c70

2

10

    cb 03

            rlc e  ; changes to bit 6 (indicates player)

#b3f2

#4c72

    Lb3f2_player:

#b3f2

#4c72

1

11

    f1

        pop af

#b3f3

#4c73

2

8

    fe 06

        cp ROBOT_ORDERS_CAPTURE_NEUTRAL_FACTORIES

#b3f5

#4c75

1

12/6

    c0

        ret nz

#b3f6

#4c76

2

8

    1e 00

        ld e, 0  ; if we are looking for neutral buildings, set e to 0 (neither player nor enemy)

#b3f8

#4c78

1

11

    c9

        ret

#b3f9

#4c79

#b3f9

#4c79

#b3f9

#4c79

    ; --------------------------------

#b3f9

#4c79

    ; Gets the target robot index, based on the orders argument.

#b3f9

#4c79

    ; Input:

#b3f9

#4c79

    ; - iy: robot

#b3f9

#4c79

    ; Output:

#b3f9

#4c79

    ; - hl: ptr to target robot

#b3f9

#4c79

    Lb3f9_find_orders_target_robot_ptr:

#b3f9

#4c79

3

11

    11 00 da

        ld de, Lda00_player1_robots

#b3fc

#4c7c

3

14

    3a 51 fd

        ld a, (Lfd51_current_robot_player_or_enemy)

#b3ff

#4c7f

1

5

    b7

        or a

#b400

#4c80

2

13/8

    20 03

        jr nz, Lb405_target_is_player_1

#b402

#4c82

3

11

    11 80 db

        ld de, Ldb80_player2_robots

#b405

#4c85

    Lb405_target_is_player_1:

#b405

#4c85

3

21

    fd 7e 0e

        ld a, (iy + ROBOT_STRUCT_ORDERS_ARGUMENT)

#b408

#4c88

1

5

    87

        add a, a

#b409

#4c89

1

5

    87

        add a, a

#b40a

#4c8a

1

5

    87

        add a, a

#b40b

#4c8b

1

5

    6f

        ld l, a

#b40c

#4c8c

2

8

    26 00

        ld h, 0

#b40e

#4c8e

1

12

    29

        add hl, hl

#b40f

#4c8f

1

12

    19

        add hl, de  ; hl = Lda00_player1/2_robots + ROBOT_STRUCT_SIZE * argument

#b410

#4c90

1

11

    c9

        ret

#b411

#4c91

#b411

#4c91

#b411

#4c91

    ; --------------------------------

#b411

#4c91

    ; Initializes some ghost registers for preparing to find the "closest" robot/building.

#b411

#4c91

    ; - Copies "hl" to "de'" (x of the reference robot)

#b411

#4c91

    ; - set "bc'" = 8192 (min distance)

#b411

#4c91

    ; - c = 0  ; current robot/building we are checking

#b411

#4c91

    ; - d = #ff  ; will store the index of the closest robot/building

#b411

#4c91

    Lb411_prepare_nearest_robot_or_building_search_registers:

#b411

#4c91

1

12

    e5

        push hl

#b412

#4c92

1

5

    d9

        exx

#b413

#4c93

1

11

    d1

            pop de

#b414

#4c94

3

11

    01 00 20

            ld bc, 8192

#b417

#4c97

1

5

    d9

        exx

#b418

#4c98

2

8

    0e 00

        ld c, 0

#b41a

#4c9a

2

8

    16 ff

        ld d, #ff

#b41c

#4c9c

1

11

    c9

        ret

#b41d

#4c9d

#b41d

#4c9d

#b41d

#4c9d

    ; --------------------------------

#b41d

#4c9d

    ; Finds the opponent robot that is nearest to the current robot.

#b41d

#4c9d

    ; Input:

#b41d

#4c9d

    ; - iy: current robot ptr.

#b41d

#4c9d

    ; Output:

#b41d

#4c9d

    ; - d: nearest robot index.

#b41d

#4c9d

    ; - z: no nearest robot.

#b41d

#4c9d

    ; - nz: some nearest robot found.

#b41d

#4c9d

    Lb41d_find_nearest_opponent_robot:

#b41d

#4c9d

3

18

    cd 11 b4

        call Lb411_prepare_nearest_robot_or_building_search_registers

#b420

#4ca0

2

17

    fd e5

        push iy

#b422

#4ca2

            ; Choose either "Lda00_player1_robots" or "Ldb80_player2_robots",

#b422

#4ca2

            ; depending on whether the current robot belongs to player or enemy AI.

#b422

#4ca2

4

16

    fd 21 00 da

            ld iy, Lda00_player1_robots  ; if current robot is enemy, search through

#b426

#4ca6

                                         ; "Lda00_player1_robots"

#b426

#4ca6

3

14

    3a 51 fd

            ld a, (Lfd51_current_robot_player_or_enemy)

#b429

#4ca9

1

5

    b7

            or a

#b42a

#4caa

2

13/8

    20 04

            jr nz, Lb430

#b42c

#4cac

4

16

    fd 21 80 db

            ld iy, Ldb80_player2_robots  ; if current robot is player, search through

#b430

#4cb0

                                         ; "Lda00_player2_robots"

#b430

#4cb0

    Lb430:

#b430

#4cb0

2

8

    06 18

            ld b, MAX_ROBOTS_PER_PLAYER

#b432

#4cb2

    Lb432_loop_robot:

#b432

#4cb2

3

21

    fd 7e 01

            ld a, (iy + 1)

#b435

#4cb5

1

5

    b7

            or a

#b436

#4cb6

2

13/8

    28 09

            jr z, Lb441_next_robot

#b438

#4cb8

3

21

    fd 6e 02

            ld l, (iy + ROBOT_STRUCT_X)

#b43b

#4cbb

3

21

    fd 66 03

            ld h, (iy + ROBOT_STRUCT_X + 1)

#b43e

#4cbe

3

18

    cd b3 b3

            call Lb3b3_check_if_nearer_than_current_nearest

#b441

#4cc1

    Lb441_next_robot:

#b441

#4cc1

1

12

    d5

            push de

#b442

#4cc2

3

11

    11 10 00

                ld de, ROBOT_STRUCT_SIZE

#b445

#4cc5

2

17

    fd 19

                add iy, de

#b447

#4cc7

1

11

    d1

            pop de

#b448

#4cc8

1

5

    0c

            inc c  ; next robot index

#b449

#4cc9

2

14/9

    10 e7

            djnz Lb432_loop_robot

#b44b

#4ccb

2

16

    fd e1

        pop iy

#b44d

#4ccd

1

5

    7a

        ld a, d

#b44e

#4cce

1

5

    3c

        inc a

#b44f

#4ccf

1

11

    c9

        ret

#b450

#4cd0

#b450

#4cd0

#b450

#4cd0

    ; --------------------------------

#b450

#4cd0

    ; Updates a robot while we are moving it in combat mode.

#b450

#4cd0

    ; Input:

#b450

#4cd0

    ; - iy: robot ptr.

#b450

#4cd0

    ; - c: possible move directions (along which there would be no collision).

#b450

#4cd0

    Lb450_robot_control_direct_control:

#b450

#4cd0

1

12

    c5

        push bc

#b451

#4cd1

3

18

    cd 7c d3

            call Ld37c_read_keyboard_joystick_input

#b454

#4cd4

1

11

    c1

        pop bc

#b455

#4cd5

1

5

    41

        ld b, c

#b456

#4cd6

3

21

    fd be 08

        cp (iy + ROBOT_STRUCT_DIRECTION)

#b459

#4cd9

        ; Since when we are requesting the robot to turn, collisions do not matter, we do not filter

#b459

#4cd9

        ; by collisions:

#b459

#4cd9

2

13/8

    20 01

        jr nz, Lb45c_keyboard_input_different_from_current_robot_direction

#b45b

#4cdb

1

5

    a1

        and c  ; we filter keyboard input keys by those directions we can actually move the robot in.

#b45c

#4cdc

    Lb45c_keyboard_input_different_from_current_robot_direction:

#b45c

#4cdc

1

5

    4f

        ld c, a  ; "c" now has the directions we want to move the robot towards, and are possible.

#b45d

#4cdd

3

18

    cd 05 b5

        call Lb505_check_number_of_directions_is_one

#b460

#4ce0

2

13/8

    28 05

        jr z, Lb467_only_one_direction

#b462

#4ce2

3

21

    fd 7e 05

        ld a, (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION)  ; get the current desired direction

#b465

#4ce5

1

5

    a0

        and b  ; "b" still had the possible move directions.

#b466

#4ce6

1

5

    4f

        ld c, a  ; if we can still move in the desired, keep moving, otherwise, stop.

#b467

#4ce7

    Lb467_only_one_direction:

#b467

#4ce7

3

21

    fd 71 05

        ld (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION), c

#b46a

#4cea

1

5

    79

        ld a, c

#b46b

#4ceb

3

14

    32 0c fd

        ld (Lfd0c_keyboard_state), a  ; overwrite the keyboard state with the filtered direction

#b46e

#4cee

3

11

    c3 0d b2

        jp Lb20d_move_robot

#b471

#4cf1

#b471

#4cf1

#b471

#4cf1

    ; --------------------------------

#b471

#4cf1

    ; Moves the robot one step in the desired direction (if currently facing it), or rotates it if

#b471

#4cf1

    ; needed.

#b471

#4cf1

    ; Input:

#b471

#4cf1

    ; - a: robot desired move direction.

#b471

#4cf1

    Lb471_move_robot_one_step_in_desired_direction:

#b471

#4cf1

1

5

    b7

        or a

#b472

#4cf2

1

12/6

    c8

        ret z  ; If robot does not want to move, return.

#b473

#4cf3

3

21

    fd be 08

        cp (iy + ROBOT_STRUCT_DIRECTION)

#b476

#4cf6

2

13/8

    28 1d

        jr z, Lb495  ; if robot is facing the right direction, just move

#b478

#4cf8

        ; rotate robot:

#b478

#4cf8

1

5

    4f

        ld c, a

#b479

#4cf9

3

21

    fd b6 08

        or (iy + ROBOT_STRUCT_DIRECTION)

#b47c

#4cfc

2

8

    fe 03

        cp #03

#b47e

#4cfe

2

13/8

    20 06

        jr nz, Lb486

#b480

#4d00

2

10

    cb 01

        rlc c  ; because of the way they organized the direction bits, to rotate 90 degrees, we need to

#b482

#4d02

               ; shift the bits w positions. Potential optimization: all the direction code can be

#b482

#4d02

               ; greatly simplified if direction bits are reordered.

#b482

#4d02

2

10

    cb 01

        rlc c

#b484

#4d04

2

13

    18 08

        jr Lb48e_new_direction_calculated

#b486

#4d06

    Lb486:

#b486

#4d06

2

8

    fe 0c

        cp #0c

#b488

#4d08

2

13/8

    20 04

        jr nz, Lb48e_new_direction_calculated

#b48a

#4d0a

2

10

    cb 09

        rrc c  ; because of the way they organized the direction bits, to rotate 90 degrees, we need to

#b48c

#4d0c

               ; shift the bits w positions

#b48c

#4d0c

2

10

    cb 09

        rrc c

#b48e

#4d0e

    Lb48e_new_direction_calculated:

#b48e

#4d0e

        ; We now have the new robot direction:

#b48e

#4d0e

3

21

    fd 71 08

        ld (iy + ROBOT_STRUCT_DIRECTION), c

#b491

#4d11

3

25

    fd 34 06

        inc (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING)  ; since this was not a move, it does

#b494

#4d14

                                                                 ; not count toward the # of steps we

#b494

#4d14

                                                                 ; want to move.

#b494

#4d14

1

11

    c9

        ret

#b495

#4d15

    Lb495:

#b495

#4d15

        ; Make the robot actually advance:

#b495

#4d15

3

18

    cd b9 b4

        call Lb4b9_robot_advance

#b498

#4d18

3

18

    cd d6 b5

        call Lb5d6_map_altitude_2x2

#b49b

#4d1b

3

21

    fd 77 0d

        ld (iy + ROBOT_STRUCT_ALTITUDE), a

#b49e

#4d1e

3

21

    fd 7e 0a

        ld a, (iy + ROBOT_STRUCT_CONTROL)  ; update the altitude of the robot based on the terrain

#b4a1

#4d21

                                           ; underneath.

#b4a1

#4d21

2

8

    fe 02

        cp ROBOT_CONTROL_DIRECT_CONTROL

#b4a3

#4d23

1

12/6

    c0

        ret nz

#b4a4

#4d24

        ; If we are here it means the player is controlling the robot directly.

#b4a4

#4d24

1

12

    c5

        push bc

#b4a5

#4d25

1

12

    e5

        push hl

#b4a6

#4d26

2

17

    fd e5

        push iy

#b4a8

#4d28

            ; This just has the effect of making the player mimic the robot movement:

#b4a8

#4d28

3

18/11

    cc 11 af

            call z, Laf11_player_ship_keyboard_control  ; Potential optimization: (not really an

#b4ab

#4d2b

                                                        ; optimization), the "z," is not needed.

#b4ab

#4d2b

2

16

    fd e1

        pop iy

#b4ad

#4d2d

1

11

    e1

        pop hl

#b4ae

#4d2e

1

11

    c1

        pop bc

#b4af

#4d2f

3

21

    fd 7e 09

        ld a, (iy + ROBOT_STRUCT_HEIGHT)

#b4b2

#4d32

3

21

    fd 86 0d

        add a, (iy + ROBOT_STRUCT_ALTITUDE)

#b4b5

#4d35

3

14

    32 10 fd

        ld (Lfd10_player_altitude), a

#b4b8

#4d38

1

11

    c9

        ret

#b4b9

#4d39

#b4b9

#4d39

#b4b9

#4d39

    ; --------------------------------

#b4b9

#4d39

    ; Moves a robot in the direction it wants to move, and update the

#b4b9

#4d39

    ; order parameters in case they were advance or retreat.

#b4b9

#4d39

    ; Input:

#b4b9

#4d39

    ; - a: desired move direction (one-hot encoding)

#b4b9

#4d39

    Lb4b9_robot_advance:

#b4b9

#4d39

1

5

    0f

        rrca

#b4ba

#4d3a

2

13/8

    30 0b

        jr nc, Lb4c7_not_right

#b4bc

#4d3c

        ; move right:

#b4bc

#4d3c

1

7

    23

        inc hl

#b4bd

#4d3d

3

21

    fd 7e 0b

        ld a, (iy + ROBOT_STRUCT_ORDERS)

#b4c0

#4d40

1

5

    3d

        dec a

#b4c1

#4d41

2

13/8

    28 2f

        jr z, Lb4f2_advance_in_direction_of_orders

#b4c3

#4d43

1

5

    3d

        dec a

#b4c4

#4d44

2

13/8

    28 18

        jr z, Lb4de_advance_against_direction_of_orders

#b4c6

#4d46

1

11

    c9

        ret

#b4c7

#4d47

#b4c7

#4d47

    Lb4c7_not_right:

#b4c7

#4d47

1

5

    0f

        rrca

#b4c8

#4d48

2

13/8

    30 0b

        jr nc, Lb4d5_not_left

#b4ca

#4d4a

        ; move left:

#b4ca

#4d4a

1

7

    2b

        dec hl

#b4cb

#4d4b

3

21

    fd 7e 0b

        ld a, (iy + ROBOT_STRUCT_ORDERS)

#b4ce

#4d4e

1

5

    3d

        dec a

#b4cf

#4d4f

2

13/8

    28 0d

        jr z, Lb4de_advance_against_direction_of_orders

#b4d1

#4d51

1

5

    3d

        dec a

#b4d2

#4d52

2

13/8

    28 1e

        jr z, Lb4f2_advance_in_direction_of_orders

#b4d4

#4d54

1

11

    c9

        ret

#b4d5

#4d55

#b4d5

#4d55

    Lb4d5_not_left:

#b4d5

#4d55

1

5

    0f

        rrca

#b4d6

#4d56

2

13/8

    30 02

        jr nc, Lb4da_not_down

#b4d8

#4d58

        ; move down:

#b4d8

#4d58

1

5

    04

        inc b

#b4d9

#4d59

1

11

    c9

        ret

#b4da

#4d5a

#b4da

#4d5a

    Lb4da_not_down:

#b4da

#4d5a

1

5

    0f

        rrca

#b4db

#4d5b

1

12/6

    d0

        ret nc

#b4dc

#4d5c

        ; move up:

#b4dc

#4d5c

1

5

    05

        dec b

#b4dd

#4d5d

1

11

    c9

        ret

#b4de

#4d5e

#b4de

#4d5e

    Lb4de_advance_against_direction_of_orders:

#b4de

#4d5e

        ; The robot moved against the direction it wants to go (e.g., its orders

#b4de

#4d5e

        ; were "retreat", but it moved to the right). So, we increment the argument

#b4de

#4d5e

        ; of the orders to compensate:

#b4de

#4d5e

3

21

    fd 7e 0a

        ld a, (iy + ROBOT_STRUCT_CONTROL)

#b4e1

#4d61

2

8

    fe 02

        cp ROBOT_CONTROL_DIRECT_CONTROL

#b4e3

#4d63

1

12/6

    c8

        ret z

#b4e4

#4d64

3

25

    fd 34 0e

        inc (iy + ROBOT_STRUCT_ORDERS_ARGUMENT)

#b4e7

#4d67

3

21

    fd 7e 0e

        ld a, (iy + ROBOT_STRUCT_ORDERS_ARGUMENT)

#b4ea

#4d6a

2

8

    fe 64

        cp 100

#b4ec

#4d6c

1

12/6

    d8

        ret c  ; do not go beyond 99 in the distance to travel.

#b4ed

#4d6d

4

21

    fd 36 0e 63

        ld (iy + ROBOT_STRUCT_ORDERS_ARGUMENT), 99

#b4f1

#4d71

1

11

    c9

        ret

#b4f2

#4d72

#b4f2

#4d72

    Lb4f2_advance_in_direction_of_orders:

#b4f2

#4d72

        ; The robot moved towards the direction it wants to go (e.g., its orders

#b4f2

#4d72

        ; were "retreat", and it moved to the left). So, we decrement the argument

#b4f2

#4d72

        ; of the orders to compensate:

#b4f2

#4d72

3

21

    fd 7e 0a

        ld a, (iy + ROBOT_STRUCT_CONTROL)

#b4f5

#4d75

2

8

    fe 02

        cp ROBOT_CONTROL_DIRECT_CONTROL

#b4f7

#4d77

1

12/6

    c8

        ret z

#b4f8

#4d78

3

25

    fd 35 0e

        dec (iy + ROBOT_STRUCT_ORDERS_ARGUMENT)

#b4fb

#4d7b

1

12/6

    c0

        ret nz

#b4fc

#4d7c

        ; When the robot advances/retreats the desired number of miles,

#b4fc

#4d7c

        ; switch to "stop & defend":

#b4fc

#4d7c

4

21

    fd 36 0b 00

        ld (iy + ROBOT_STRUCT_ORDERS), ROBOT_ORDERS_STOP_AND_DEFEND

#b500

#4d80

4

21

    fd 36 06 00

        ld (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), 0

#b504

#4d84

1

11

    c9

        ret

#b505

#4d85

#b505

#4d85

#b505

#4d85

    ; --------------------------------

#b505

#4d85

    ; Counts the number of bits in the lower nibble of "c" that are set to 1, and checks

#b505

#4d85

    ; if there is only 1 such bit on.

#b505

#4d85

    ; Input:

#b505

#4d85

    ; - c: one-hot representation of the directions we want to move the robot in.

#b505

#4d85

    Lb505_check_number_of_directions_is_one:

#b505

#4d85

    Lb505_count_number_of_active_bits_in_the_lower_nibble:

#b505

#4d85

1

12

    c5

        push bc

#b506

#4d86

2

8

    06 04

            ld b, 4  ; only consider the lower 4 bis

#b508

#4d88

1

5

    af

            xor a

#b509

#4d89

    Lb509_direction_loop:

#b509

#4d89

2

10

    cb 19

            rr c

#b50b

#4d8b

2

8

    ce 00

            adc a, 0  ; if the bit was set, increment a, otherwise do not increment.

#b50d

#4d8d

2

14/9

    10 fa

            djnz Lb509_direction_loop

#b50f

#4d8f

1

11

    c1

        pop bc

#b510

#4d90

2

8

    fe 01

        cp 1  ; check that the number of bits set to 1 was just 1.

#b512

#4d92

1

11

    c9

        ret

#b513

#4d93

#b513

#4d93

#b513

#4d93

    ; --------------------------------

#b513

#4d93

    ; Checks which directions can a robot move in, and in which it will collide.

#b513

#4d93

    ; Input:

#b513

#4d93

    ; - iy: robot ptr.

#b513

#4d93

    ; Output:

#b513

#4d93

    ; - c: lower 4 bits indicate if robot can move right, left, up, down.

#b513

#4d93

    Lb513_get_robot_movement_possibilities:

#b513

#4d93

2

8

    0e 00

        ld c, 0

#b515

#4d95

        ; Check if the player is above or below robot height, to see if the player

#b515

#4d95

        ; is an obstacle or not.

#b515

#4d95

3

14

    3a 10 fd

        ld a, (Lfd10_player_altitude)

#b518

#4d98

3

21

    fd 96 09

        sub (iy + ROBOT_STRUCT_HEIGHT)

#b51b

#4d9b

3

21

    fd 96 0d

        sub (iy + ROBOT_STRUCT_ALTITUDE)

#b51e

#4d9e

2

8

    e6 80

        and 128  ; If the player is lower than the robot height, player is also an obstable

#b520

#4da0

2

8

    f6 40

        or #40

#b522

#4da2

1

5

    5f

        ld e, a  ; e contains a mask to check if a given position in the map is not walkable due to

#b523

#4da3

                 ; player or another robot.

#b523

#4da3

3

21

    fd 7e 07

        ld a, (iy + ROBOT_STRUCT_PIECES)

#b526

#4da6

2

8

    16 08

        ld d, 8  ; if chassis is bipod, d = 8

#b528

#4da8

1

5

    0f

        rrca

#b529

#4da9

2

13/8

    38 07

        jr c, Lb532

#b52b

#4dab

2

8

    16 0c

        ld d, 12  ; if chassis is tracks, d = 12

#b52d

#4dad

1

5

    0f

        rrca

#b52e

#4dae

2

13/8

    38 02

        jr c, Lb532

#b530

#4db0

2

8

    16 0f

        ld d, 15  ; if chassis is antigrav, d = 15

#b532

#4db2

    Lb532:

#b532

#4db2

1

12

    e5

        push hl

#b533

#4db3

3

18

    cd 57 b5

            call Lb557_check_robot_collision_inc_x

#b536

#4db6

1

11

    e1

        pop hl

#b537

#4db7

2

13/8

    20 02

        jr nz, Lb53b_collision_right

#b539

#4db9

2

10

    cb c1

        set 0, c  ; mark that we can move to the right

#b53b

#4dbb

    Lb53b_collision_right:

#b53b

#4dbb

1

12

    e5

        push hl

#b53c

#4dbc

3

18

    cd 6f b5

            call Lb56f_check_robot_collision_dec_x

#b53f

#4dbf

1

11

    e1

        pop hl

#b540

#4dc0

2

13/8

    20 02

        jr nz, Lb544_collision_left

#b542

#4dc2

2

10

    cb c9

        set 1, c  ; mark that we can move to the left

#b544

#4dc4

    Lb544_collision_left:

#b544

#4dc4

1

12

    e5

        push hl

#b545

#4dc5

3

18

    cd 8f b5

            call Lb58f_check_robot_collision_inc_y

#b548

#4dc8

1

11

    e1

        pop hl

#b549

#4dc9

2

13/8

    20 02

        jr nz, Lb54d_collision_down

#b54b

#4dcb

2

10

    cb d1

        set 2, c  ; mark that we can move down

#b54d

#4dcd

    Lb54d_collision_down:

#b54d

#4dcd

1

12

    e5

        push hl

#b54e

#4dce

3

18

    cd b1 b5

            call Lb5b1_check_robot_collision_dec_y

#b551

#4dd1

1

11

    e1

        pop hl

#b552

#4dd2

2

13/8

    20 02

        jr nz, Lb556_up

#b554

#4dd4

2

10

    cb d9

        set 3, c  ; mark that we can move up

#b556

#4dd6

    Lb556_up:

#b556

#4dd6

1

11

    c9

        ret

#b557

#4dd7

#b557

#4dd7

#b557

#4dd7

    ; --------------------------------

#b557

#4dd7

    ; Checks if a robot can walk to the right (incrementing x).

#b557

#4dd7

    ; Input:

#b557

#4dd7

    ; - hl: map pointer

#b557

#4dd7

    ; - d: 8 for bipod, 12 for tracks, and 15 for antigrav (the highest map element a robot can walk

#b557

#4dd7

    ;      over).

#b557

#4dd7

    ; - e: mask of non-walkable elements (usually just #40 to indicate other robots are not walkable).

#b557

#4dd7

    ;      But it could be #c0 when the player is lower than the height of the robot in consideration,

#b557

#4dd7

    ;      to consider the player as an obstacle.

#b557

#4dd7

    Lb557_check_robot_collision_inc_x:

#b557

#4dd7

1

7

    23

        inc hl

#b558

#4dd8

1

7

    23

        inc hl  ; x += 2

#b559

#4dd9

1

5

    25

        dec h

#b55a

#4dda

1

5

    25

        dec h  ; y -= 1

#b55b

#4ddb

3

18

    cd cd b5

        call Lb5cd_robot_map_collision_internal

#b55e

#4dde

1

12/6

    c0

        ret nz  ; collision

#b55f

#4ddf

1

5

    24

        inc h  ; y += 1

#b560

#4de0

1

5

    24

        inc h

#b561

#4de1

3

18

    cd cd b5

        call Lb5cd_robot_map_collision_internal

#b564

#4de4

1

12/6

    c0

        ret nz  ; collision

#b565

#4de5

1

5

    24

        inc h  ; y += 1

#b566

#4de6

1

5

    24

        inc h

#b567

#4de7

1

5

    7c

        ld a, h

#b568

#4de8

2

8

    fe fd

        cp #fd  ; check if we are out of map bounds

#b56a

#4dea

2

13/8

    30 5c

        jr nc, Lb5c8_no_collision

#b56c

#4dec

1

8

    7e

        ld a, (hl)

#b56d

#4ded

1

5

    a3

        and e

#b56e

#4dee

1

11

    c9

        ret

#b56f

#4def

#b56f

#4def

#b56f

#4def

    ; --------------------------------

#b56f

#4def

    ; Checks if a robot can walk to the left (decrementing x).

#b56f

#4def

    ; Input:

#b56f

#4def

    ; - hl: map pointer

#b56f

#4def

    ; - d: 8 for bipod, 12 for tracks, and 15 for antigrav (the highest map element a robot can walk

#b56f

#4def

    ;      over).

#b56f

#4def

    ; - e: mask of non-walkable elements (usually just #40 to indicate other robots are not walkable).

#b56f

#4def

    ;      But it could be #c0 when the player is lower than the height of the robot in consideration,

#b56f

#4def

    ;      to consider the player as an obstacle.

#b56f

#4def

    Lb56f_check_robot_collision_dec_x:

#b56f

#4def

1

5

    25

        dec h  ; y -= 1

#b570

#4df0

1

5

    25

        dec h

#b571

#4df1

1

7

    2b

        dec hl  ; x -= 1

#b572

#4df2

3

18

    cd cd b5

        call Lb5cd_robot_map_collision_internal

#b575

#4df5

1

12/6

    c0

        ret nz  ; collision

#b576

#4df6

1

7

    2b

        dec hl  ; x -= 1

#b577

#4df7

1

8

    7e

        ld a, (hl)

#b578

#4df8

1

5

    a3

        and e

#b579

#4df9

1

12/6

    c0

        ret nz  ; collision

#b57a

#4dfa

1

5

    24

        inc h  ; y += 1

#b57b

#4dfb

1

5

    24

        inc h

#b57c

#4dfc

1

8

    7e

        ld a, (hl)

#b57d

#4dfd

1

5

    a3

        and e

#b57e

#4dfe

1

12/6

    c0

        ret nz  ; collision

#b57f

#4dff

1

7

    23

        inc hl  ; x += 1

#b580

#4e00

3

18

    cd cd b5

        call Lb5cd_robot_map_collision_internal

#b583

#4e03

1

12/6

    c0

        ret nz  ; collision

#b584

#4e04

1

7

    2b

        dec hl  ; x -= 1

#b585

#4e05

1

5

    24

        inc h

#b586

#4e06

1

5

    24

        inc h  ; y += 1

#b587

#4e07

1

5

    7c

        ld a, h

#b588

#4e08

2

8

    fe fd

        cp #fd  ; check if we are out of map bounds

#b58a

#4e0a

2

13/8

    30 3c

        jr nc, Lb5c8_no_collision

#b58c

#4e0c

1

8

    7e

        ld a, (hl)

#b58d

#4e0d

1

5

    a3

        and e

#b58e

#4e0e

1

11

    c9

        ret

#b58f

#4e0f

#b58f

#4e0f

#b58f

#4e0f

    ; --------------------------------

#b58f

#4e0f

    ; Checks if a robot can walk down (incrementing y).

#b58f

#4e0f

    ; Input:

#b58f

#4e0f

    ; - hl: map pointer

#b58f

#4e0f

    ; - d: 8 for bipod, 12 for tracks, and 15 for antigrav (the highest map element a robot can walk

#b58f

#4e0f

    ;      over).

#b58f

#4e0f

    ; - e: mask of non-walkable elements (usually just #40 to indicate other robots are not walkable).

#b58f

#4e0f

    ;      But it could be #c0 when the player is lower than the height of the robot in consideration,

#b58f

#4e0f

    ;      to consider the player as an obstacle.

#b58f

#4e0f

    Lb58f_check_robot_collision_inc_y:

#b58f

#4e0f

1

5

    24

        inc h  ; y += 1

#b590

#4e10

1

5

    24

        inc h

#b591

#4e11

1

5

    7c

        ld a, h

#b592

#4e12

2

8

    fe fd

        cp #fd

#b594

#4e14

2

13/8

    30 34

        jr nc, Lb5ca_collision  ; check if we are out of map bounds

#b596

#4e16

3

18

    cd cd b5

        call Lb5cd_robot_map_collision_internal

#b599

#4e19

1

12/6

    c0

        ret nz

#b59a

#4e1a

1

7

    23

        inc hl  ; x += 1

#b59b

#4e1b

3

18

    cd cd b5

        call Lb5cd_robot_map_collision_internal

#b59e

#4e1e

1

12/6

    c0

        ret nz

#b59f

#4e1f

1

5

    24

        inc h  ; y += 1

#b5a0

#4e20

1

5

    24

        inc h

#b5a1

#4e21

1

5

    7c

        ld a, h

#b5a2

#4e22

2

8

    fe fd

        cp #fd  ; check if we are out of map bounds

#b5a4

#4e24

2

13/8

    30 22

        jr nc, Lb5c8_no_collision

#b5a6

#4e26

1

8

    7e

        ld a, (hl)

#b5a7

#4e27

1

5

    a3

        and e

#b5a8

#4e28

1

12/6

    c0

        ret nz

#b5a9

#4e29

1

7

    2b

        dec hl  ; x -= 1

#b5aa

#4e2a

1

8

    7e

        ld a, (hl)

#b5ab

#4e2b

1

5

    a3

        and e

#b5ac

#4e2c

1

12/6

    c0

        ret nz

#b5ad

#4e2d

1

7

    2b

        dec hl  ; x -= 1

#b5ae

#4e2e

1

8

    7e

        ld a, (hl)

#b5af

#4e2f

1

5

    a3

        and e

#b5b0

#4e30

1

11

    c9

        ret

#b5b1

#4e31

#b5b1

#4e31

#b5b1

#4e31

    ; --------------------------------

#b5b1

#4e31

    ; Checks if a robot can walk up (decrementing y).

#b5b1

#4e31

    ; Input:

#b5b1

#4e31

    ; - hl: map pointer

#b5b1

#4e31

    ; - d: 8 for bipod, 12 for tracks, and 15 for antigrav (the highest map element a robot can walk

#b5b1

#4e31

    ;      over).

#b5b1

#4e31

    ; - e: mask of non-walkable elements (usually just #40 to indicate other robots are not walkable).

#b5b1

#4e31

    ;      But it could be #c0 when the player is lower than the height of the robot in consideration,

#b5b1

#4e31

    ;      to consider the player as an obstacle.

#b5b1

#4e31

    Lb5b1_check_robot_collision_dec_y:

#b5b1

#4e31

1

5

    25

        dec h

#b5b2

#4e32

1

5

    25

        dec h  ; y -= 1

#b5b3

#4e33

1

5

    25

        dec h

#b5b4

#4e34

1

5

    25

        dec h  ; y -= 1

#b5b5

#4e35

1

5

    7c

        ld a, h

#b5b6

#4e36

2

8

    fe dd

        cp #dd  ; check if we are out of map bounds

#b5b8

#4e38

2

13/8

    38 10

        jr c, Lb5ca_collision

#b5ba

#4e3a

1

7

    2b

        dec hl  ; x -= 1

#b5bb

#4e3b

1

8

    7e

        ld a, (hl)

#b5bc

#4e3c

1

5

    a3

        and e

#b5bd

#4e3d

1

12/6

    c0

        ret nz

#b5be

#4e3e

1

7

    23

        inc hl  ; x += 1

#b5bf

#4e3f

3

18

    cd cd b5

        call Lb5cd_robot_map_collision_internal

#b5c2

#4e42

1

12/6

    c0

        ret nz

#b5c3

#4e43

1

7

    23

        inc hl  ; x += 1

#b5c4

#4e44

3

18

    cd cd b5

        call Lb5cd_robot_map_collision_internal

#b5c7

#4e47

1

11

    c9

        ret

#b5c8

#4e48

    Lb5c8_no_collision:

#b5c8

#4e48

1

5

    af

        xor a

#b5c9

#4e49

1

11

    c9

        ret

#b5ca

#4e4a

    Lb5ca_collision:

#b5ca

#4e4a

2

8

    f6 01

        or 1

#b5cc

#4e4c

1

11

    c9

        ret

#b5cd

#4e4d

#b5cd

#4e4d

#b5cd

#4e4d

    ; --------------------------------

#b5cd

#4e4d

    ; Check if a given position in the map is walkable by the chassis of a robot.

#b5cd

#4e4d

    ; This is checked by seeing if the element in the map is < "d".

#b5cd

#4e4d

    ; Input:

#b5cd

#4e4d

    ; - hl: map pointer

#b5cd

#4e4d

    ; - d: 8 for bipod, 12 for tracks, and 15 for antigrav (the highest map element a robot can walk

#b5cd

#4e4d

    ;      over).

#b5cd

#4e4d

    ; - e: mask of non-walkable elements (usually just #40 to indicate other robots are not walkable).

#b5cd

#4e4d

    ;      But it could be #c0 when the player is lower than the height of the robot in consideration,

#b5cd

#4e4d

    ;      to consider the player as an obstacle.

#b5cd

#4e4d

    Lb5cd_robot_map_collision_internal:

#b5cd

#4e4d

1

8

    7e

        ld a, (hl)

#b5ce

#4e4e

2

8

    e6 1f

        and #1f

#b5d0

#4e50

1

5

    ba

        cp d

#b5d1

#4e51

2

13/8

    30 f7

        jr nc, Lb5ca_collision  ; map element is not walkable by the current chassis.

#b5d3

#4e53

1

8

    7e

        ld a, (hl)

#b5d4

#4e54

1

5

    a3

        and e  ; check for objects (robots and potentially the player)

#b5d5

#4e55

1

11

    c9

        ret

#b5d6

#4e56

#b5d6

#4e56

#b5d6

#4e56

    ; --------------------------------

#b5d6

#4e56

    ; Get highest altitude of 2x2 map area:

#b5d6

#4e56

    ; input:

#b5d6

#4e56

    ; - hl: x

#b5d6

#4e56

    ; - b: y

#b5d6

#4e56

    ; Output:

#b5d6

#4e56

    ; - a: altitude

#b5d6

#4e56

    Lb5d6_map_altitude_2x2:

#b5d6

#4e56

1

12

    e5

        push hl

#b5d7

#4e57

1

12

    c5

        push bc

#b5d8

#4e58

1

5

    78

            ld a, b

#b5d9

#4e59

3

18

    cd a6 cc

            call Lcca6_compute_map_ptr

#b5dc

#4e5c

1

5

    eb

            ex de, hl

#b5dd

#4e5d

2

8

    0e 00

            ld c, 0

#b5df

#4e5f

3

18

    cd 8a b0

            call Lb08a_get_map_altitude

#b5e2

#4e62

1

7

    13

            inc de

#b5e3

#4e63

3

18

    cd 8a b0

            call Lb08a_get_map_altitude

#b5e6

#4e66

1

5

    15

            dec d

#b5e7

#4e67

1

5

    15

            dec d

#b5e8

#4e68

3

18

    cd 8a b0

            call Lb08a_get_map_altitude

#b5eb

#4e6b

1

7

    1b

            dec de

#b5ec

#4e6c

3

18

    cd 8a b0

            call Lb08a_get_map_altitude

#b5ef

#4e6f

1

5

    79

            ld a, c

#b5f0

#4e70

1

11

    c1

        pop bc

#b5f1

#4e71

1

11

    e1

        pop hl

#b5f2

#4e72

1

11

    c9

        ret

#b5f3

#4e73

#b5f3

#4e73

#b5f3

#4e73

    ; --------------------------------

#b5f3

#4e73

    ; Determines how many cycles will the robot need to take to move

#b5f3

#4e73

    ; depending on the terrain it is on.

#b5f3

#4e73

    ; Input:

#b5f3

#4e73

    ; - iy: robot pointer

#b5f3

#4e73

    Lb5f3_determine_speed_based_on_terrain:

#b5f3

#4e73

1

12

    c5

        push bc

#b5f4

#4e74

1

12

    e5

        push hl

#b5f5

#4e75

3

21

    fd 7e 0d

            ld a, (iy + ROBOT_STRUCT_ALTITUDE)

#b5f8

#4e78

2

8

    0e 00

            ld c, 0  ; flat terrain

#b5fa

#4e7a

1

5

    b7

            or a

#b5fb

#4e7b

2

13/8

    28 08

            jr z, Lb605_terrain_type_determined

#b5fd

#4e7d

2

8

    0e 03

            ld c, 3  ; rugged

#b5ff

#4e7f

2

8

    fe 04

            cp 4

#b601

#4e81

2

13/8

    38 02

            jr c, Lb605_terrain_type_determined

#b603

#4e83

2

8

    0e 06

            ld c, 6  ; mountains

#b605

#4e85

    Lb605_terrain_type_determined:

#b605

#4e85

3

21

    fd 7e 07

            ld a, (iy + ROBOT_STRUCT_PIECES)

#b608

#4e88

2

8

    16 ff

            ld d, 255

#b60a

#4e8a

    Lb60a_determine_chassis_loop:

#b60a

#4e8a

1

5

    14

            inc d

#b60b

#4e8b

1

5

    0f

            rrca

#b60c

#4e8c

2

13/8

    30 fc

            jr nc, Lb60a_determine_chassis_loop

#b60e

#4e8e

1

5

    79

            ld a, c

#b60f

#4e8f

1

5

    82

            add a, d

#b610

#4e90

3

11

    21 1d b6

            ld hl, Lb61d_robot_movement_speed_table

#b613

#4e93

3

18

    cd 51 d3

            call Ld351_add_hl_a

#b616

#4e96

1

8

    7e

            ld a, (hl)

#b617

#4e97

3

21

    fd 77 0f

            ld (iy + ROBOT_STRICT_CYCLES_TO_NEXT_UPDATE), a

#b61a

#4e9a

1

11

    e1

        pop hl

#b61b

#4e9b

1

11

    c1

        pop bc

#b61c

#4e9c

1

11

    c9

        ret

#b61d

#4e9d

#b61d

#4e9d

    ; How many cycles does the robot take to move in the different terrains,

#b61d

#4e9d

    ; depending on its chassis:

#b61d

#4e9d

    Lb61d_robot_movement_speed_table:

#b61d

#4e9d

        ;  bipod, tracks, anti-grav

#b61d

#4e9d

3

        db #06, #04, #03  ; flat terrain

#b620

#4ea0

3

        db #08, #06, #03  ; rugged

#b623

#4ea3

3

        db #09, #07, #04  ; mountains

#b626

#4ea6

#b626

#4ea6

#b626

#4ea6

    ; --------------------------------

#b626

#4ea6

    ; Looks in the 4 cardinal directions to see if in any of them there are enemy robots

#b626

#4ea6

    ; that we could fire at.

#b626

#4ea6

    ; Input:

#b626

#4ea6

    ; - iy: robot ptr.

#b626

#4ea6

    ; Output:

#b626

#4ea6

    ; - e: one-hot representation of the directions where enemy robots can be found.

#b626

#4ea6

    Lb626_check_directions_with_enemy_robots:

#b626

#4ea6

2

8

    1e 00

        ld e, 0  ; will accumulate the directions in which there are enemy robots in line.

#b628

#4ea8

2

8

    16 08

        ld d, 8  ; initial direction (up in a one-hot encoded representation)

#b62a

#4eaa

    Lb62a_loop_direction:

#b62a

#4eaa

2

10

    cb 03

        rlc e

#b62c

#4eac

3

21

    fd 6e 00

        ld l, (iy + ROBOT_STRUCT_MAP_PTR)

#b62f

#4eaf

3

21

    fd 66 01

        ld h, (iy + ROBOT_STRUCT_MAP_PTR + 1)

#b632

#4eb2

2

8

    06 08

        ld b, 8  ; distance to check in directions we are not facing

#b634

#4eb4

1

5

    7a

        ld a, d

#b635

#4eb5

3

21

    fd be 08

        cp (iy + ROBOT_STRUCT_DIRECTION)

#b638

#4eb8

2

13/8

    20 2c

        jr nz, Lb666_simple_check

#b63a

#4eba

2

8

    06 0a

        ld b, 10  ; look a bit further in the direction we are facing

#b63c

#4ebc

4

22

    fd cb 07 7e

        bit 7, (iy + ROBOT_STRUCT_PIECES)

#b640

#4ec0

2

13/8

    28 02

        jr z, Lb644

#b642

#4ec2

2

8

    06 0c

        ld b, 12  ; if robot has "electronics", it can see a bit further still.

#b644

#4ec4

    Lb644:

#b644

#4ec4

1

5

    7a

        ld a, d

#b645

#4ec5

2

8

    e6 03

        and #03

#b647

#4ec7

2

13/8

    20 0e

        jr nz, Lb657

#b649

#4ec9

        ; Look along the y axis (left/right):

#b649

#4ec9

1

5

    48

        ld c, b  ; store the max distance for later

#b64a

#4eca

1

7

    2b

        dec hl  ; check with an offset of 1 tile up

#b64b

#4ecb

3

18

    cd 6e b6

        call Lb66e_check_if_enemy_robot_in_line

#b64e

#4ece

1

5

    41

        ld b, c  ; restore the max distance

#b64f

#4ecf

1

7

    23

        inc hl  ; check with no offset

#b650

#4ed0

3

18

    cd 6e b6

        call Lb66e_check_if_enemy_robot_in_line

#b653

#4ed3

1

5

    41

        ld b, c  ; restore the max distance

#b654

#4ed4

1

7

    23

        inc hl  ; check with an offset of 1 tile down

#b655

#4ed5

2

13

    18 0f

        jr Lb666_simple_check

#b657

#4ed7

    Lb657:

#b657

#4ed7

        ; Look along the x axis (up/down):

#b657

#4ed7

1

5

    48

        ld c, b  ; store the max distance for later

#b658

#4ed8

1

5

    25

        dec h

#b659

#4ed9

1

5

    25

        dec h  ; check with an offset of 1 tile left

#b65a

#4eda

3

18

    cd 6e b6

        call Lb66e_check_if_enemy_robot_in_line

#b65d

#4edd

1

5

    41

        ld b, c  ; restore the max distance

#b65e

#4ede

1

5

    24

        inc h  ; check with no offset

#b65f

#4edf

1

5

    24

        inc h  ; check with an offset of 1 tile right

#b660

#4ee0

3

18

    cd 6e b6

        call Lb66e_check_if_enemy_robot_in_line

#b663

#4ee3

1

5

    41

        ld b, c  ; restore the max distance

#b664

#4ee4

1

5

    24

        inc h

#b665

#4ee5

1

5

    24

        inc h

#b666

#4ee6

    Lb666_simple_check:

#b666

#4ee6

        ; Just check in a straight line without adjusting the offset:

#b666

#4ee6

3

18

    cd 6e b6

        call Lb66e_check_if_enemy_robot_in_line

#b669

#4ee9

2

10

    cb 0a

        rrc d  ; next direction

#b66b

#4eeb

2

13/8

    30 bd

        jr nc, Lb62a_loop_direction

#b66d

#4eed

1

11

    c9

        ret

#b66e

#4eee

#b66e

#4eee

#b66e

#4eee

    ; --------------------------------

#b66e

#4eee

    ; Checks if there is an enemy robot in line with the current robot in the desired direction.

#b66e

#4eee

    ; Basically, to see if we fired a weapon in that direction, if we could hit an enemy robot.

#b66e

#4eee

    ; Input:

#b66e

#4eee

    ; - hl: map ptr.

#b66e

#4eee

    ; - b: maximum distance to check.

#b66e

#4eee

    ; - d: direction (one-hot representation).

#b66e

#4eee

    ; - e: current directions at which we found enemy robots.

#b66e

#4eee

    ; Output:

#b66e

#4eee

    ; - e: updated with whether we found an enemy robot in the current direction.

#b66e

#4eee

    Lb66e_check_if_enemy_robot_in_line:

#b66e

#4eee

1

12

    e5

        push hl

#b66f

#4eef

1

12

    d5

            push de

#b670

#4ef0

1

12

    e5

                push hl

#b671

#4ef1

3

11

    21 ae b6

                    ld hl, Lb6b0_direction_offsets - 2

#b674

#4ef4

1

5

    7a

                    ld a, d

#b675

#4ef5

                    ; get the position from the Lb6b0_direction_offsets array corresponding to the

#b675

#4ef5

                    ; one-hot bit in "d", and store it in "de"

#b675

#4ef5

    Lb675_get_word_loop:

#b675

#4ef5

1

7

    23

                    inc hl

#b676

#4ef6

1

7

    23

                    inc hl

#b677

#4ef7

1

5

    0f

                    rrca

#b678

#4ef8

2

13/8

    30 fb

                    jr nc, Lb675_get_word_loop

#b67a

#4efa

1

8

    5e

                    ld e, (hl)

#b67b

#4efb

1

7

    23

                    inc hl

#b67c

#4efc

1

8

    56

                    ld d, (hl)

#b67d

#4efd

1

11

    e1

                pop hl

#b67e

#4efe

                ; Keeps advancing in the desired direction until we get out of the map,

#b67e

#4efe

                ; or we find an object.

#b67e

#4efe

    Lb67e_raycast_loop:

#b67e

#4efe

1

12

    19

                add hl, de  ; add the offset to the map ptr.

#b67f

#4eff

1

5

    7c

                ld a, h

#b680

#4f00

2

8

    d6 dd

                sub #dd

#b682

#4f02

2

8

    fe 20

                cp 16 * 2

#b684

#4f04

2

13/8

    30 27

                jr nc, Lb6ad_nothing_found  ; out of bounds of the map

#b686

#4f06

2

14

    cb 76

                bit 6, (hl)

#b688

#4f08

2

13/8

    20 04

                jr nz, Lb68e_object_found  ; object found

#b68a

#4f0a

2

14/9

    10 f2

                djnz Lb67e_raycast_loop

#b68c

#4f0c

2

13

    18 1f

                jr Lb6ad_nothing_found

#b68e

#4f0e

#b68e

#4f0e

    Lb68e_object_found:

#b68e

#4f0e

2

17

    fd e5

                push iy

#b690

#4f10

3

18

    cd d8 cd

                    call Lcdd8_get_robot_at_ptr

#b693

#4f13

3

21

    fd 7e 0a

                    ld a, (iy + ROBOT_STRUCT_CONTROL)

#b696

#4f16

3

21

    fd 46 0c

                    ld b, (iy + ROBOT_STRUCT_STRENGTH)

#b699

#4f19

2

16

    fd e1

                pop iy

#b69b

#4f1b

2

13/8

    20 10

                jr nz, Lb6ad_nothing_found

#b69d

#4f1d

3

21

    fd ae 0a

                xor (iy + ROBOT_STRUCT_CONTROL)

#b6a0

#4f20

3

11

    f2 ad b6

                jp p, Lb6ad_nothing_found  ; the robot has the same owner as the current robot.

#b6a3

#4f23

1

5

    05

                dec b

#b6a4

#4f24

3

11

    fa ad b6

                jp m, Lb6ad_nothing_found  ; the robot is already destroyed

#b6a7

#4f27

1

11

    d1

            pop de

#b6a8

#4f28

1

5

    7b

            ld a, e

#b6a9

#4f29

2

8

    f6 01

            or 1

#b6ab

#4f2b

1

5

    5f

            ld e, a  ; potential optimization: these 3 instructions are just "set 0, e".

#b6ac

#4f2c

1

12

    d5

            push de  ; push just to make sure the next pop does not mess up the stack.

#b6ad

#4f2d

    Lb6ad_nothing_found:

#b6ad

#4f2d

1

11

    d1

            pop de

#b6ae

#4f2e

    Lb6ae:

#b6ae

#4f2e

1

11

    e1

        pop hl

#b6af

#4f2f

1

11

    c9

        ret

#b6b0

#4f30

#b6b0

#4f30

    Lb6b0_direction_offsets:

#b6b0

#4f30

2

        dw 1  ; right

#b6b2

#4f32

2

        dw -1  ; left

#b6b4

#4f34

2

        dw 512  ; down

#b6b6

#4f36

2

        dw -512  ; up

#b6b8

#4f38

#b6b8

#4f38

#b6b8

#4f38

    ; --------------------------------

#b6b8

#4f38

    ; Find new bullet pointer. Friendly robots can only use bullets 1, and 2,

#b6b8

#4f38

    ; and enemy robots bullets 3 and 4 (bullet 0 is reserved for player-controlled robots).

#b6b8

#4f38

    ; Input:

#b6b8

#4f38

    ; - ix: pointer to robot that is firing.

#b6b8

#4f38

    ; Output:

#b6b8

#4f38

    ; - iy: new bullet ptr

#b6b8

#4f38

    ; - z: new bullet found

#b6b8

#4f38

    ; - nz: no bullet slots available.

#b6b8

#4f38

    Lb6b8_find_new_bullet_ptr:

#b6b8

#4f38

4

16

    fd 21 dc d7

        ld iy, Ld7d3_bullets + BULLET_STRUCT_SIZE

#b6bc

#4f3c

4

22

    dd cb 0a 7e

        bit 7, (ix + ROBOT_STRUCT_CONTROL)

#b6c0

#4f40

2

13/8

    28 05

        jr z, Lb6c7_player_robot

#b6c2

#4f42

3

11

    11 12 00

        ld de, BULLET_STRUCT_SIZE * 2

#b6c5

#4f45

2

17

    fd 19

        add iy, de

#b6c7

#4f47

    Lb6c7_player_robot:

#b6c7

#4f47

3

21

    fd 7e 01

        ld a, (iy + 1)

#b6ca

#4f4a

1

5

    b7

        or a

#b6cb

#4f4b

1

12/6

    c8

        ret z  ; first bullet is available

#b6cc

#4f4c

        ; Try next bullet:

#b6cc

#4f4c

3

11

    11 09 00

        ld de, BULLET_STRUCT_SIZE

#b6cf

#4f4f

2

17

    fd 19

        add iy, de

#b6d1

#4f51

3

21

    fd 7e 01

        ld a, (iy + 1)

#b6d4

#4f54

1

5

    b7

        or a

#b6d5

#4f55

1

11

    c9

        ret

#b6d6

#4f56

#b6d6

#4f56

#b6d6

#4f56

    ; --------------------------------

#b6d6

#4f56

    ; Spawns a new bullet on "iy".

#b6d6

#4f56

    ; Input:

#b6d6

#4f56

    ; - a: weapon to fire: 1: cannon, 2: missiles, 3: phasers.

#b6d6

#4f56

    ; - iy: bullet pointer to use.

#b6d6

#4f56

    ; - ix: pointer to robot that fired the weapon.

#b6d6

#4f56

    Lb6d6_weapon_fire:

#b6d6

#4f56

3

21

    fd 77 07

        ld (iy + BULLET_STRUCT_TYPE), a

#b6d9

#4f59

2

8

    0e 05

        ld c, WEAPON_RANGE_DEFAULT  ; range

#b6db

#4f5b

2

8

    fe 02

        cp 2  ; missiles

#b6dd

#4f5d

2

13/8

    20 02

        jr nz, Lb6e1_not_missiles

#b6df

#4f5f

2

8

    0e 07

        ld c, WEAPON_RANGE_MISSILES  ; missiles have an extended range

#b6e1

#4f61

    Lb6e1_not_missiles:

#b6e1

#4f61

4

22

    dd cb 07 7e

        bit 7, (ix + ROBOT_STRUCT_PIECES)

#b6e5

#4f65

2

13/8

    28 01

        jr z, Lb6e8_not_electronics

#b6e7

#4f67

1

5

    0c

        inc c  ; electronics increase by one the weapon range

#b6e8

#4f68

    Lb6e8_not_electronics:

#b6e8

#4f68

3

21

    fd 71 06

        ld (iy + BULLET_STRUCT_RANGE), c

#b6eb

#4f6b

3

21

    dd 7e 08

        ld a, (ix + ROBOT_STRUCT_DIRECTION)

#b6ee

#4f6e

3

21

    fd 77 05

        ld (iy + BULLET_STRUCT_DIRECTION), a

#b6f1

#4f71

4

21

    fd 36 08 0a

        ld (iy + BULLET_STRUCT_ALTITUDE), 10

#b6f5

#4f75

3

21

    dd 6e 02

        ld l, (ix + ROBOT_STRUCT_X)

#b6f8

#4f78

3

21

    dd 66 03

        ld h, (ix + ROBOT_STRUCT_X + 1)

#b6fb

#4f7b

3

21

    dd 46 04

        ld b, (ix + ROBOT_STRUCT_Y)

#b6fe

#4f7e

3

18

    cd 24 b7

        call Lb724_bullet_update_internal

#b701

#4f81

3

21

    fd 7e 01

        ld a, (iy + 1)

#b704

#4f84

1

5

    b7

        or a

#b705

#4f85

2

13/8

    28 05

        jr z, Lb70c

#b707

#4f87

2

8

    3e 01

        ld a, 1

#b709

#4f89

3

14

    32 53 fd

        ld (Lfd53_produce_in_game_sound), a  ; produce sound

#b70c

#4f8c

    Lb70c:

#b70c

#4f8c

1

11

    c9

        ret

#b70d

#4f8d

#b70d

#4f8d

#b70d

#4f8d

    ; --------------------------------

#b70d

#4f8d

    ; Update cycle for bullets, including dealing damage to robots.

#b70d

#4f8d

    ; Input:

#b70d

#4f8d

    ; - iy: bullet ptr

#b70d

#4f8d

    Lb70d_bullet_update:

#b70d

#4f8d

3

21

    fd 6e 00

        ld l, (iy + BULLET_STRUCT_MAP_PTR)

#b710

#4f90

3

21

    fd 66 01

        ld h, (iy + BULLET_STRUCT_MAP_PTR + 1)

#b713

#4f93

2

17

    cb b6

        res 6, (hl)  ; remove the bullet from the map

#b715

#4f95

3

25

    fd 35 06

        dec (iy + BULLET_STRUCT_RANGE)  ; decrease the lifetime of the bullet

#b718

#4f98

3

11

    ca ea b7

        jp z, Lb7ea_bullet_disappear  ; if bullet has reached its maximum range, destroy it

#b71b

#4f9b

3

21

    fd 6e 02

        ld l, (iy + BULLET_STRUCT_X)

#b71e

#4f9e

3

21

    fd 66 03

        ld h, (iy + BULLET_STRUCT_X + 1)

#b721

#4fa1

3

21

    fd 46 04

        ld b, (iy + BULLET_STRUCT_Y)

#b724

#4fa4

    Lb724_bullet_update_internal:

#b724

#4fa4

        ; move the bullet in the direction of movement:

#b724

#4fa4

3

21

    fd 7e 05

        ld a, (iy + BULLET_STRUCT_DIRECTION)

#b727

#4fa7

1

5

    0f

        rrca

#b728

#4fa8

2

13/8

    30 04

        jr nc, Lb72e_not_right

#b72a

#4faa

1

7

    23

        inc hl  ; x += 2

#b72b

#4fab

1

7

    23

        inc hl

#b72c

#4fac

2

13

    18 19

        jr Lb747_movement_complete

#b72e

#4fae

    Lb72e_not_right:

#b72e

#4fae

1

5

    0f

        rrca

#b72f

#4faf

2

13/8

    30 04

        jr nc, Lb735_not_left

#b731

#4fb1

1

7

    2b

        dec hl  ; x -= 2

#b732

#4fb2

1

7

    2b

        dec hl

#b733

#4fb3

2

13

    18 12

        jr Lb747_movement_complete

#b735

#4fb5

    Lb735_not_left:

#b735

#4fb5

1

5

    0f

        rrca

#b736

#4fb6

2

13/8

    30 04

        jr nc, Lb73c_not_down

#b738

#4fb8

1

5

    04

        inc b  ; y += 2

#b739

#4fb9

1

5

    04

        inc b

#b73a

#4fba

2

13

    18 05

        jr Lb741_check_out_of_map_in_y

#b73c

#4fbc

    Lb73c_not_down:

#b73c

#4fbc

1

5

    0f

        rrca

#b73d

#4fbd

2

13/8

    30 08

        jr nc, Lb747_movement_complete

#b73f

#4fbf

1

5

    05

        dec b  ; y -= 2

#b740

#4fc0

1

5

    05

        dec b

#b741

#4fc1

    Lb741_check_out_of_map_in_y:

#b741

#4fc1

        ; Notice that we only need to check out of bounds in the y axis, as, in the x axis, there's

#b741

#4fc1

        ; always obstacles at the ends of the map, so, we don't need to check.

#b741

#4fc1

1

5

    78

        ld a, b

#b742

#4fc2

2

8

    fe 10

        cp MAP_WIDTH

#b744

#4fc4

3

11

    d2 ea b7

        jp nc, Lb7ea_bullet_disappear  ; if y > 16 or < 0, make it disappear.

#b747

#4fc7

    Lb747_movement_complete:

#b747

#4fc7

3

21

    fd 75 02

        ld (iy + BULLET_STRUCT_X), l

#b74a

#4fca

3

21

    fd 74 03

        ld (iy + BULLET_STRUCT_X + 1), h

#b74d

#4fcd

3

21

    fd 70 04

        ld (iy + BULLET_STRUCT_Y), b

#b750

#4fd0

        ; Check if the bullet collided with the map:

#b750

#4fd0

3

18

    cd d6 b5

        call Lb5d6_map_altitude_2x2

#b753

#4fd3

3

21

    fd be 08

        cp (iy + BULLET_STRUCT_ALTITUDE)

#b756

#4fd6

3

11

    d2 ea b7

        jp nc, Lb7ea_bullet_disappear  ; collision

#b759

#4fd9

1

5

    78

        ld a, b

#b75a

#4fda

        ; Calculate the new map pointer given the new position:

#b75a

#4fda

3

18

    cd a6 cc

        call Lcca6_compute_map_ptr

#b75d

#4fdd

3

21

    fd 75 00

        ld (iy + BULLET_STRUCT_MAP_PTR), l

#b760

#4fe0

3

21

    fd 74 01

        ld (iy + BULLET_STRUCT_MAP_PTR + 1), h

#b763

#4fe3

1

12

    e5

        push hl

#b764

#4fe4

1

7

    2b

            dec hl  ; x -= 1

#b765

#4fe5

1

5

    25

            dec h  ; y -= 1

#b766

#4fe6

1

5

    25

            dec h

#b767

#4fe7

1

5

    7c

            ld a, h

#b768

#4fe8

2

8

    fe dd

            cp #dd  ; check if the pointer is out of the map area

#b76a

#4fea

2

13/8

    38 10

            jr c, Lb77c_continue  ; out of bounds in that direction, so, we can skip a few collision

#b76c

#4fec

                                  ; checks.

#b76c

#4fec

2

14

    cb 76

            bit 6, (hl)

#b76e

#4fee

2

13/8

    20 37

            jr nz, Lb7a7_potentially_hit_a_robot

#b770

#4ff0

1

7

    23

            inc hl  ; x += 1

#b771

#4ff1

2

14

    cb 76

            bit 6, (hl)

#b773

#4ff3

2

13/8

    20 32

            jr nz, Lb7a7_potentially_hit_a_robot

#b775

#4ff5

1

7

    23

            inc hl  ; x += 1

#b776

#4ff6

2

14

    cb 76

            bit 6, (hl)

#b778

#4ff8

2

13/8

    20 2d

            jr nz, Lb7a7_potentially_hit_a_robot

#b77a

#4ffa

1

7

    2b

            dec hl  ; restore the x coordinate

#b77b

#4ffb

1

7

    2b

            dec hl

#b77c

#4ffc

    Lb77c_continue:

#b77c

#4ffc

1

5

    24

            inc h  ; y += 1

#b77d

#4ffd

1

5

    24

            inc h

#b77e

#4ffe

2

14

    cb 76

            bit 6, (hl)

#b780

#5000

2

13/8

    20 25

            jr nz, Lb7a7_potentially_hit_a_robot

#b782

#5002

1

7

    23

            inc hl  ; x += 1

#b783

#5003

2

14

    cb 76

            bit 6, (hl)

#b785

#5005

2

13/8

    20 20

            jr nz, Lb7a7_potentially_hit_a_robot

#b787

#5007

1

7

    23

            inc hl  ; x += 1

#b788

#5008

2

14

    cb 76

            bit 6, (hl)

#b78a

#500a

2

13/8

    20 1b

            jr nz, Lb7a7_potentially_hit_a_robot

#b78c

#500c

1

7

    2b

            dec hl  ; x -= 2

#b78d

#500d

1

7

    2b

            dec hl

#b78e

#500e

1

5

    24

            inc h  ; y += 1

#b78f

#500f

1

5

    24

            inc h

#b790

#5010

1

5

    7c

            ld a, h

#b791

#5011

2

8

    fe fd

            cp #fd  ; check if the pointer is out of the map area

#b793

#5013

2

13/8

    30 0e

            jr nc, Lb7a3_no_robot_collision

#b795

#5015

2

14

    cb 76

            bit 6, (hl)

#b797

#5017

2

13/8

    20 0e

            jr nz, Lb7a7_potentially_hit_a_robot

#b799

#5019

1

7

    23

            inc hl

#b79a

#501a

2

14

    cb 76

            bit 6, (hl)

#b79c

#501c

2

13/8

    20 09

            jr nz, Lb7a7_potentially_hit_a_robot

#b79e

#501e

1

7

    23

            inc hl

#b79f

#501f

2

14

    cb 76

            bit 6, (hl)

#b7a1

#5021

2

13/8

    20 04

            jr nz, Lb7a7_potentially_hit_a_robot

#b7a3

#5023

    Lb7a3_no_robot_collision:

#b7a3

#5023

1

11

    e1

        pop hl

#b7a4

#5024

2

17

    cb f6

        set 6, (hl)  ; we mark the bullet in the map again

#b7a6

#5026

1

11

    c9

        ret

#b7a7

#5027

    Lb7a7_potentially_hit_a_robot:

#b7a7

#5027

2

17

    fd e5

            push iy

#b7a9

#5029

3

21

    fd 5e 07

                ld e, (iy + BULLET_STRUCT_TYPE)

#b7ac

#502c

2

8

    0e fc

                ld c, 252  ; c determines the SFX that will be played with this event

#b7ae

#502e

3

18

    cd d8 cd

                call Lcdd8_get_robot_at_ptr

#b7b1

#5031

2

13/8

    20 2b

                jr nz, Lb7de_collision_handled

#b7b3

#5033

3

21

    fd 7e 0c

                ld a, (iy + ROBOT_STRUCT_STRENGTH)

#b7b6

#5036

1

5

    3d

                dec a

#b7b7

#5037

3

11

    fa de b7

                jp m, Lb7de_collision_handled  ; robot was already destroyed

#b7ba

#503a

                ; Determine the damage dealt:

#b7ba

#503a

2

8

    3e 3c

                ld a, 60

#b7bc

#503c

3

21

    fd 96 09

                sub (iy + ROBOT_STRUCT_HEIGHT)

#b7bf

#503f

3

21

    fd 96 0d

                sub (iy + ROBOT_STRUCT_ALTITUDE)

#b7c2

#5042

2

10

    cb 3f

                srl a

#b7c4

#5044

2

10

    cb 3f

                srl a

#b7c6

#5046

1

5

    57

                ld d, a  ; d = "base damage" = (60 - (robot height + altitude)) / 4

#b7c7

#5047

1

5

    43

                ld b, e  ; bullet type (1: cannon, 2: missiles, 3: phaser)

#b7c8

#5048

    Lb7c8_damage_calculation_loop:

#b7c8

#5048

1

5

    82

                add a, d

#b7c9

#5049

2

14/9

    10 fd

                djnz Lb7c8_damage_calculation_loop

#b7cb

#504b

                ; Here a = 2x base damage for cannon, 3x for missiles, and 4x for phasers.

#b7cb

#504b

1

5

    47

                ld b, a

#b7cc

#504c

2

8

    0e fa

                ld c, 250  ; sfx

#b7ce

#504e

3

21

    fd 7e 0c

                ld a, (iy + ROBOT_STRUCT_STRENGTH)

#b7d1

#5051

1

5

    90

                sub b  ; deal damage

#b7d2

#5052

2

13/8

    28 03

                jr z, Lb7d7_robot_destroyed

#b7d4

#5054

3

11

    f2 db b7

                jp p, Lb7db_robot_hit

#b7d7

#5057

    Lb7d7_robot_destroyed:

#b7d7

#5057

2

8

    3e fc

                ld a, -4  ; mark negative strength, which will make the robot blink before being

#b7d9

#5059

                          ; destroyed.

#b7d9

#5059

2

8

    0e c8

                ld c, 200  ; sfx

#b7db

#505b

    Lb7db_robot_hit:

#b7db

#505b

3

21

    fd 77 0c

                ld (iy + ROBOT_STRUCT_STRENGTH), a  ; update robot health

#b7de

#505e

    Lb7de_collision_handled:

#b7de

#505e

2

16

    fd e1

            pop iy

#b7e0

#5060

1

11

    e1

        pop hl

#b7e1

#5061

4

21

    fd 36 01 00

        ld (iy + BULLET_STRUCT_MAP_PTR + 1), 0  ; make the bullet disappear

#b7e5

#5065

1

5

    79

        ld a, c

#b7e6

#5066

3

14

    32 53 fd

        ld (Lfd53_produce_in_game_sound), a  ; produce sound

#b7e9

#5069

1

11

    c9

        ret

#b7ea

#506a

#b7ea

#506a

#b7ea

#506a

    ; --------------------------------

#b7ea

#506a

    ; Make a bullet disappear.

#b7ea

#506a

    ; Input:

#b7ea

#506a

    ; - iy: bullet pointer.

#b7ea

#506a

    Lb7ea_bullet_disappear:

#b7ea

#506a

4

21

    fd 36 01 00

        ld (iy + 1), 0

#b7ee

#506e

2

8

    3e fc

        ld a, -4

#b7f0

#5070

3

14

    32 53 fd

        ld (Lfd53_produce_in_game_sound), a  ; produce sound

#b7f3

#5073

1

11

    c9

        ret

#b7f4

#5074

#b7f4

#5074

#b7f4

#5074

    ; --------------------------------

#b7f4

#5074

    ; Enemy AI update cycle. It works as follows:

#b7f4

#5074

    ; - with probability 0.25 it does nothing.

#b7f4

#5074

    ; - it then tries to pick a robot at random (from the set of 24 possible robots).

#b7f4

#5074

    ; - if it's an active robot, it will control it via "Lb920_enemy_ai_single_robot_control"

#b7f4

#5074

    ; - otherwise, it picks a random warbase

#b7f4

#5074

    ; - if it belongs to the enemy, it will try to produce a random robot with come constraints.

#b7f4

#5074

    ; - if any of the constraints is violated, then the enemy AI will just do nothing.

#b7f4

#5074

    ; - otherwise, it will construct the robot with "stop & defend" orders, and wait for it

#b7f4

#5074

    ;   to be randomly picked up later to be assigned new orders.

#b7f4

#5074

    Lb7f4_update_enemy_ai:

#b7f4

#5074

3

18

    cd 58 d3

        call Ld358_random

#b7f7

#5077

2

8

    e6 1f

        and #1f

#b7f9

#5079

2

8

    fe 18

        cp MAX_ROBOTS_PER_PLAYER

#b7fb

#507b

1

12/6

    d0

        ret nc  ; with 0.25 probability the enemy AI does nothing.

#b7fc

#507c

        ; Use the generated random number to get the pointer of a robot at random:

#b7fc

#507c

1

5

    87

        add a, a

#b7fd

#507d

1

5

    87

        add a, a

#b7fe

#507e

1

5

    87

        add a, a

#b7ff

#507f

1

5

    6f

        ld l, a

#b800

#5080

2

8

    26 00

        ld h, 0

#b802

#5082

1

12

    29

        add hl, hl

#b803

#5083

3

11

    11 80 db

        ld de, Ldb80_player2_robots

#b806

#5086

1

12

    19

        add hl, de

#b807

#5087

1

12

    e5

        push hl

#b808

#5088

2

16

    fd e1

        pop iy  ; iy now has the pointer to a random robot from the enemy AI.

#b80a

#508a

2

8

    3e 01

        ld a, 1

#b80c

#508c

3

14

    32 51 fd

        ld (Lfd51_current_robot_player_or_enemy), a

#b80f

#508f

        ; Check if the pointer corresponds to an active robot:

#b80f

#508f

3

21

    fd 7e 01

        ld a, (iy + ROBOT_STRUCT_MAP_PTR + 1)

#b812

#5092

1

5

    b7

        or a

#b813

#5093

3

11

    c2 20 b9

        jp nz, Lb920_enemy_ai_single_robot_control

#b816

#5096

#b816

#5096

        ; pick a random warbase otherwise:

#b816

#5096

2

8

    06 04

        ld b, N_WARBASES

#b818

#5098

3

11

    21 73 fd

        ld hl, Lfd70_warbases + BUILDING_STRUCT_TYPE

#b81b

#509b

    Lb81b_pick_random_warbase_loop:

#b81b

#509b

3

18

    cd 58 d3

        call Ld358_random

#b81e

#509e

2

8

    e6 01

        and 1

#b820

#50a0

2

13/8

    28 05

        jr z, Lb827_next_warbase

#b822

#50a2

1

8

    7e

        ld a, (hl)

#b823

#50a3

2

8

    fe 20

        cp #20

#b825

#50a5

2

13/8

    28 08

        jr z, Lb0ca_enemy_ai_control_warbase  ; also ensures it's a warbase

#b827

#50a7

    Lb827_next_warbase:

#b827

#50a7

2

8

    3e 05

        ld a, BUILDING_STRUCT_SIZE

#b829

#50a9

3

18

    cd 51 d3

        call Ld351_add_hl_a

#b82c

#50ac

2

14/9

    10 ed

        djnz Lb81b_pick_random_warbase_loop

#b82e

#50ae

        ; no warbase selected

#b82e

#50ae

1

11

    c9

        ret

#b82f

#50af

#b82f

#50af

    Lb0ca_enemy_ai_control_warbase:

#b82f

#50af

        ; Notice that if we reached here, "iy" has the pointer to an empty

#b82f

#50af

        ; robot position.

#b82f

#50af

1

7

    2b

        dec hl

#b830

#50b0

1

8

    46

        ld b, (hl)

#b831

#50b1

1

7

    2b

        dec hl

#b832

#50b2

1

8

    7e

        ld a, (hl)

#b833

#50b3

1

7

    2b

        dec hl

#b834

#50b4

1

8

    6e

        ld l, (hl)

#b835

#50b5

1

5

    67

        ld h, a  ; hl = x coordinate, b = y coordinate

#b836

#50b6

1

5

    78

        ld a, b

#b837

#50b7

1

12

    e5

        push hl

#b838

#50b8

1

5

    d9

            exx

#b839

#50b9

1

11

    e1

        pop hl

#b83a

#50ba

1

5

    47

        ld b, a  ; hl = x coordinate, b = y coordinate in both ghost and regular registers

#b83b

#50bb

                 ; this is to set the robot coordinates below.

#b83b

#50bb

1

5

    d9

        exx

#b83c

#50bc

3

18

    cd a6 cc

        call Lcca6_compute_map_ptr

#b83f

#50bf

        ; Check if the entrance to the warbase is blocked:

#b83f

#50bf

1

12

    e5

        push hl

#b840

#50c0

1

8

    7e

            ld a, (hl)

#b841

#50c1

1

5

    24

            inc h

#b842

#50c2

1

5

    24

            inc h

#b843

#50c3

1

8

    b6

            or (hl)

#b844

#50c4

1

7

    2b

            dec hl

#b845

#50c5

1

8

    b6

            or (hl)

#b846

#50c6

1

7

    23

            inc hl

#b847

#50c7

1

7

    23

            inc hl

#b848

#50c8

1

8

    b6

            or (hl)

#b849

#50c9

2

8

    e6 40

            and #40

#b84b

#50cb

1

11

    e1

        pop hl

#b84c

#50cc

1

12/6

    c0

        ret nz  ; if there is something blocking the entrance of the warbase, exit.

#b84d

#50cd

3

18

    cd 58 d3

        call Ld358_random  ; Note: not sure why calling random twice.

#b850

#50d0

3

18

    cd 58 d3

        call Ld358_random

#b853

#50d3

1

5

    4f

        ld c, a  ; save the random number for later

#b854

#50d4

3

21

    fd 77 07

        ld (iy + ROBOT_STRUCT_PIECES), a

#b857

#50d7

2

8

    e6 07

        and 7

#b859

#50d9

2

8

    fe 01

        cp 1  ; bipod

#b85b

#50db

2

13/8

    28 07

        jr z, Lb864_correct_chasis

#b85d

#50dd

2

8

    fe 02

        cp 2  ; tracks

#b85f

#50df

2

13/8

    28 03

        jr z, Lb864_correct_chasis

#b861

#50e1

2

8

    fe 04

        cp 4  ; antigrav

#b863

#50e3

1

12/6

    c0

        ret nz  ; if we picked more than one chassis, just return.

#b864

#50e4

    Lb864_correct_chasis:

#b864

#50e4

1

5

    79

        ld a, c  ; restore the random number

#b865

#50e5

1

5

    0f

        rrca

#b866

#50e6

1

5

    0f

        rrca

#b867

#50e7

1

5

    0f

        rrca

#b868

#50e8

2

8

    e6 0f

        and #0f

#b86a

#50ea

1

12/6

    c8

        ret z  ; if we picked no weapon, just return.

#b86b

#50eb

2

8

    fe 0f

        cp #0f

#b86d

#50ed

1

12/6

    c8

        ret z  ; if we picked too many weapons (only 3 allowed), just return.

#b86e

#50ee

1

5

    4f

        ld c, a  ; save the weapon selection

#b86f

#50ef

3

14

    3a 49 fd

        ld a, (Lfd49_player2_robot_count)

#b872

#50f2

1

5

    0f

        rrca

#b873

#50f3

1

5

    0f

        rrca

#b874

#50f4

1

5

    0f

        rrca

#b875

#50f5

1

5

    3c

        inc a

#b876

#50f6

2

8

    e6 03

        and 3

#b878

#50f8

1

5

    47

        ld b, a  ; enemy # of robots / 8 + 1

#b879

#50f9

3

18

    cd 05 b5

        call Lb505_count_number_of_active_bits_in_the_lower_nibble

#b87c

#50fc

1

5

    b8

        cp b

#b87d

#50fd

1

12/6

    d8

        ret c  ; the first 8 robots, can at most have 1 weapon, the next 8 can have two, etc.

#b87e

#50fe

#b87e

#50fe

        ; Check if player 2 has enough resources:

#b87e

#50fe

3

11

    21 4a fd

        ld hl, Lfd4a_player2_resource_counts

#b881

#5101

3

11

    11 29 fd

        ld de, Lfd29_resource_counts_buffer

#b884

#5104

3

11

    01 07 00

        ld bc, 7

#b887

#5107

2

23/18

    ed b0

        ldir

#b889

#5109

3

21

    fd 4e 07

        ld c, (iy + ROBOT_STRUCT_PIECES)

#b88c

#510c

2

8

    16 00

        ld d, 0  ; how many "general resources" will we need to use.

#b88e

#510e

2

8

    06 08

        ld b, 8

#b890

#5110

    Lb890_check_resource_availability_loop:

#b890

#5110

2

10

    cb 09

        rrc c

#b892

#5112

2

13/8

    30 24

        jr nc, Lb8b8_next_piece

#b894

#5114

2

8

    3e 08

        ld a, 8

#b896

#5116

1

5

    90

        sub b

#b897

#5117

1

12

    f5

        push af

#b898

#5118

3

11

    21 f0 ca

            ld hl, Lcaf0_piece_costs

#b89b

#511b

3

18

    cd 51 d3

            call Ld351_add_hl_a

#b89e

#511e

1

8

    5e

            ld e, (hl)  ; cost of the piece

#b89f

#511f

1

11

    f1

        pop af

#b8a0

#5120

3

11

    21 f8 ca

        ld hl, Lcaf8_piece_factory_type

#b8a3

#5123

3

18

    cd 51 d3

        call Ld351_add_hl_a

#b8a6

#5126

1

8

    7e

        ld a, (hl)  ; type of factory that can produce this piece

#b8a7

#5127

3

11

    21 29 fd

        ld hl, Lfd29_resource_counts_buffer

#b8aa

#512a

3

18

    cd 51 d3

        call Ld351_add_hl_a

#b8ad

#512d

1

8

    7e

        ld a, (hl)

#b8ae

#512e

1

5

    93

        sub e

#b8af

#512f

3

11

    f2 b7 b8

        jp p, Lb8b7_no_need_for_general_resources

#b8b2

#5132

2

10

    ed 44

        neg

#b8b4

#5134

1

5

    82

        add a, d  ; add the left over to the general resources cost

#b8b5

#5135

1

5

    57

        ld d, a

#b8b6

#5136

1

5

    af

        xor a  ; zero out the resources we have left for this factory type.

#b8b7

#5137

    Lb8b7_no_need_for_general_resources:

#b8b7

#5137

1

8

    77

        ld (hl), a

#b8b8

#5138

    Lb8b8_next_piece:

#b8b8

#5138

2

14/9

    10 d6

        djnz Lb890_check_resource_availability_loop

#b8ba

#513a

        ; Check that we have enough general resources:

#b8ba

#513a

3

11

    21 29 fd

        ld hl, Lfd29_resource_counts_buffer

#b8bd

#513d

1

8

    7e

        ld a, (hl)

#b8be

#513e

2

10

    cb 3f

        srl a

#b8c0

#5140

2

8

    fe 0b

        cp 11

#b8c2

#5142

2

13/8

    30 02

        jr nc, Lb8c6_more_than_22_resources_left

#b8c4

#5144

2

8

    3e 0b

        ld a, 11

#b8c6

#5146

    Lb8c6_more_than_22_resources_left:

#b8c6

#5146

1

5

    ba

        cp d

#b8c7

#5147

1

12/6

    d8

        ret c  ; The maximum general resources we can spend on a robot is half of the amount we have (

#b8c8

#5148

               ; except if we need to spend less or equal to 11).

#b8c8

#5148

#b8c8

#5148

1

8

    7e

        ld a, (hl)

#b8c9

#5149

1

5

    92

        sub d

#b8ca

#514a

1

12/6

    f8

        ret m  ; we do not have enough resources to build the robot, return.

#b8cb

#514b

#b8cb

#514b

        ; subtract the costs from the actual player 2 resources:

#b8cb

#514b

1

8

    77

        ld (hl), a

#b8cc

#514c

3

11

    11 4a fd

        ld de, Lfd4a_player2_resource_counts

#b8cf

#514f

3

11

    01 07 00

        ld bc, 7

#b8d2

#5152

2

23/18

    ed b0

        ldir

#b8d4

#5154

#b8d4

#5154

        ; Start the robot!

#b8d4

#5154

4

21

    fd 36 0a 80

        ld (iy + ROBOT_STRUCT_CONTROL), ROBOT_CONTROL_ENEMY_AI  ; mark the owner

#b8d8

#5158

1

5

    d9

        exx

#b8d9

#5159

3

18

    cd 7c cc

            call Lcc7c_set_robot_position  ; set position

#b8dc

#515c

1

5

    d9

        exx

#b8dd

#515d

4

21

    fd 36 05 04

        ld (iy + ROBOT_STRUCT_DESIRED_MOVE_DIRECTION), 4  ; by default move down (to exit the warbase)

#b8e1

#5161

4

21

    fd 36 08 04

        ld (iy + ROBOT_STRUCT_DIRECTION), 4

#b8e5

#5165

4

21

    fd 36 06 03

        ld (iy + ROBOT_STRUCT_NUMBER_OF_STEPS_TO_KEEP_WALKING), 3

#b8e9

#5169

4

21

    fd 36 0d 00

        ld (iy + ROBOT_STRUCT_ALTITUDE), 0

#b8ed

#516d

4

21

    fd 36 0b 00

        ld (iy + ROBOT_STRUCT_ORDERS), ROBOT_ORDERS_STOP_AND_DEFEND

#b8f1

#5171

4

21

    fd 36 0f 01

        ld (iy + ROBOT_STRICT_CYCLES_TO_NEXT_UPDATE), 1

#b8f5

#5175

4

21

    fd 36 0c 64

        ld (iy + ROBOT_STRUCT_STRENGTH), 100

#b8f9

#5179

4

21

    fd 36 0e ff

        ld (iy + ROBOT_STRUCT_ORDERS_ARGUMENT), 255

#b8fd

#517d

        ; calculate robot height (when a player constructs it, this is calculated in the robot editing

#b8fd

#517d

        ; UI):

#b8fd

#517d

3

21

    fd 4e 07

        ld c, (iy + ROBOT_STRUCT_PIECES)

#b900

#5180

2

8

    06 08

        ld b, 8

#b902

#5182

2

8

    16 00

        ld d, 0

#b904

#5184

    Lb904_robot_height_loop:

#b904

#5184

2

10

    cb 09

        rrc c

#b906

#5186

2

13/8

    30 0c

        jr nc, Lb914_next_piece

#b908

#5188

2

8

    3e 08

        ld a, 8

#b90a

#518a

1

5

    90

        sub b

#b90b

#518b

3

11

    21 b4 d7

        ld hl, Ld7b4_piece_heights

#b90e

#518e

3

18

    cd 51 d3

        call Ld351_add_hl_a

#b911

#5191

1

8

    7e

        ld a, (hl)

#b912

#5192

1

5

    82

        add a, d

#b913

#5193

1

5

    57

        ld d, a

#b914

#5194

    Lb914_next_piece:

#b914

#5194

2

14/9

    10 ee

        djnz Lb904_robot_height_loop

#b916

#5196

3

21

    fd 72 09

        ld (iy + ROBOT_STRUCT_HEIGHT), d

#b919

#5199

3

18

    cd 40 bb

        call Lbb40_count_robots

#b91c

#519c

3

18

    cd 93 d2

        call Ld293_update_stats_in_right_hud

#b91f

#519f

1

11

    c9

        ret

#b920

#51a0

#b920

#51a0

#b920

#51a0

    ; --------------------------------

#b920

#51a0

    ; If the robot already has orders (!= from "stop & defend"):

#b920

#51a0

    ; - with a 1 / 32 chance they will be kept.

#b920

#51a0

    ; - if the robot target is of the type it was looking for, a new order will be given (note: I think

#b920

#51a0

    ;   this is a bug, look my other note below).

#b920

#51a0

    ; - if the robot has not reached the target, a new order will be given.

#b920

#51a0

    ; If new orders are to be given:

#b920

#51a0

    ; - if robot has nuclear, it will try to randomly go and destroy player factories/warbases.

#b920

#51a0

    ; - otherwise, capture neutral/player factories or player warbases.

#b920

#51a0

    ; - if it cannot find a target, then destroy player robots.

#b920

#51a0

    ; Input:

#b920

#51a0

    ; - iy: robot ptr.

#b920

#51a0

    Lb920_enemy_ai_single_robot_control:

#b920

#51a0

3

21

    fd 7e 0b

        ld a, (iy + ROBOT_STRUCT_ORDERS)

#b923

#51a3

1

5

    b7

        or a

#b924

#51a4

2

13/8

    28 37

        jr z, Lb95d_assign_new_orders  ; if current orders are stop & defend

#b926

#51a6

#b926

#51a6

        ; The robot already had orders different from stop & defend.

#b926

#51a6

1

5

    47

        ld b, a

#b927

#51a7

3

18

    cd 58 d3

        call Ld358_random

#b92a

#51aa

2

8

    e6 1f

        and #1f

#b92c

#51ac

1

12/6

    c0

        ret nz  ; 1 / 32 chance to keep the same orders the robot still has.

#b92d

#51ad

1

5

    78

        ld a, b

#b92e

#51ae

2

8

    fe 04

        cp ROBOT_ORDERS_DESTROY_ENEMY_FACTORIES

#b930

#51b0

2

13/8

    38 2b

        jr c, Lb95d_assign_new_orders  ; if orders where stop & defend, advance, retreat or destroy

#b932

#51b2

                                       ; robots, assign new orders.

#b932

#51b2

#b932

#51b2

        ; Otherwise, look for a target:

#b932

#51b2

3

21

    fd 7e 0b

        ld a, (iy + ROBOT_STRUCT_ORDERS)

#b935

#51b5

3

18

    cd d5 b3

        call Lb3d5_prepare_robot_order_building_target_search

#b938

#51b8

3

21

    fd 7e 0e

        ld a, (iy + ROBOT_STRUCT_ORDERS_ARGUMENT)

#b93b

#51bb

1

5

    47

        ld b, a

#b93c

#51bc

1

5

    87

        add a, a

#b93d

#51bd

1

5

    87

        add a, a

#b93e

#51be

1

5

    80

        add a, b

#b93f

#51bf

3

18

    cd 51 d3

        call Ld351_add_hl_a  ; hl now contains a pointer to the target building type flag

#b942

#51c2

1

8

    7e

        ld a, (hl)

#b943

#51c3

2

8

    e6 e0

        and #e0

#b945

#51c5

1

5

    bb

        cp e  ; compare if the target flags are the same as we are looking for.

#b946

#51c6

2

13/8

    28 15

        jr z, Lb95d_assign_new_orders  ; if the robot's target was a correct one, assign new orders (

#b948

#51c8

                                       ; note: this is strange, I think this is a bug, and it was meant

#b948

#51c8

                                       ; to be "nz").

#b948

#51c8

        ; Now check, if the robot has arrived to the target, keep orders, otherwise, change.

#b948

#51c8

1

7

    2b

        dec hl

#b949

#51c9

3

21

    fd 7e 04

        ld a, (iy + ROBOT_STRUCT_Y)

#b94c

#51cc

1

8

    96

        sub (hl)

#b94d

#51cd

2

13/8

    20 0e

        jr nz, Lb95d_assign_new_orders  ; if the target is not in the same "y" coordinate, assign new

#b94f

#51cf

                                        ; orders.

#b94f

#51cf

1

7

    2b

        dec hl

#b950

#51d0

1

8

    56

        ld d, (hl)

#b951

#51d1

1

7

    2b

        dec hl

#b952

#51d2

1

8

    5e

        ld e, (hl)

#b953

#51d3

3

21

    fd 6e 02

        ld l, (iy + ROBOT_STRUCT_X)

#b956

#51d6

3

21

    fd 66 03

        ld h, (iy + ROBOT_STRUCT_X + 1)

#b959

#51d9

1

5

    af

        xor a

#b95a

#51da

2

17

    ed 52

        sbc hl, de

#b95c

#51dc

1

12/6

    c8

        ret z  ; if the robot is in the same "x" coordinate as the target, keep the orders!

#b95d

#51dd

#b95d

#51dd

    Lb95d_assign_new_orders:

#b95d

#51dd

        ; Randomly assigns a robot to destroy/capture factories or warbases.

#b95d

#51dd

        ; - destroy if the robot has nuclear, and capture if it does not.

#b95d

#51dd

        ; - in case it cannot find a target for the random orders it was assigned, it will just

#b95d

#51dd

        ;   be tasked to destroy player robots.

#b95d

#51dd

4

21

    fd 36 0b 03

        ld (iy + ROBOT_STRUCT_ORDERS), ROBOT_ORDERS_DESTROY_ENEMY_ROBOTS  ; Potential optimization:

#b961

#51e1

                                                                          ; this assignment will always

#b961

#51e1

                                                                          ; be overwritten. So, it can

#b961

#51e1

                                                                          ; be eliminated.

#b961

#51e1

4

22

    fd cb 07 76

        bit 6, (iy + ROBOT_STRUCT_PIECES)

#b965

#51e5

2

13/8

    28 0f

        jr z, Lb976_robot_does_not_have_nuclear

#b967

#51e7

        ; robot has nuclear:

#b967

#51e7

        ; randomly assign it to destroy either player factories or player warbases:

#b967

#51e7

3

18

    cd 58 d3

        call Ld358_random

#b96a

#51ea

1

5

    47

        ld b, a

#b96b

#51eb

1

5

    07

        rlca

#b96c

#51ec

1

5

    b0

        or b

#b96d

#51ed

2

8

    e6 01

        and 1

#b96f

#51ef

2

8

    c6 04

        add a, ROBOT_ORDERS_DESTROY_ENEMY_FACTORIES

#b971

#51f1

3

21

    fd 77 0b

        ld (iy + ROBOT_STRUCT_ORDERS), a

#b974

#51f4

2

13

    18 13

        jr Lb989_new_orders_assigned

#b976

#51f6

#b976

#51f6

    Lb976_robot_does_not_have_nuclear:

#b976

#51f6

        ; Randomly assign it to capture: neutral factories, enemy factories or enemy warbases:

#b976

#51f6

2

8

    0e 00

        ld c, ROBOT_ORDERS_STOP_AND_DEFEND

#b978

#51f8

3

18

    cd 58 d3

        call Ld358_random

#b97b

#51fb

1

5

    0f

        rrca

#b97c

#51fc

2

13/8

    38 05

        jr c, Lb983

#b97e

#51fe

1

5

    0c

        inc c

#b97f

#51ff

1

5

    0f

        rrca

#b980

#5200

2

13/8

    38 01

        jr c, Lb983

#b982

#5202

1

5

    0c

        inc c

#b983

#5203

    Lb983:

#b983

#5203

1

5

    79

        ld a, c

#b984

#5204

2

8

    c6 06

        add a, ROBOT_ORDERS_CAPTURE_NEUTRAL_FACTORIES

#b986

#5206

3

21

    fd 77 0b

        ld (iy + ROBOT_STRUCT_ORDERS), a

#b989

#5209

#b989

#5209

    Lb989_new_orders_assigned:

#b989

#5209

3

21

    fd 6e 02

        ld l, (iy + ROBOT_STRUCT_X)

#b98c

#520c

3

21

    fd 66 03

        ld h, (iy + ROBOT_STRUCT_X + 1)

#b98f

#520f

4

21

    fd 36 0e ff

        ld (iy + ROBOT_STRUCT_ORDERS_ARGUMENT), 255

#b993

#5213

3

18

    cd 4d b3

        call Lb34d_find_capture_or_destroy_target

#b996

#5216

3

21

    fd 72 0e

        ld (iy + ROBOT_STRUCT_ORDERS_ARGUMENT), d

#b999

#5219

1

12/6

    c0

        ret nz  ; if target found, we are done.

#b99a

#521a

        ; Otherwise, just try to destroy enemy robots

#b99a

#521a

4

21

    fd 36 0b 03

        ld (iy + ROBOT_STRUCT_ORDERS), ROBOT_ORDERS_DESTROY_ENEMY_ROBOTS

#b99e

#521e

1

11

    c9

        ret

#b99f

#521f

#b99f

#521f

#b99f

#521f

    ; --------------------------------

#b99f

#521f

    ; Nuclear bomb effect: destroys buildings and robots nearby and replace with debris.

#b99f

#521f

    ; Input:

#b99f

#521f

    ; - iy: robot pointer.

#b99f

#521f

    Lb99f_fire_nuclear_bomb:

#b99f

#521f

3

11

    21 73 fd

        ld hl, Lfd70_warbases + BUILDING_STRUCT_TYPE

#b9a2

#5222

2

8

    0e 00

        ld c, 0  ; building index

#b9a4

#5224

3

11

    11 0a 07

        ld de, #070a  ; nuclear bomb effect radius for warbases (something in between a circle and a

#b9a7

#5227

                      ; square):

#b9a7

#5227

                      ; - maximum distance in each axis of 7

#b9a7

#5227

                      ; - maximum sum of distances in each axis of 10

#b9a7

#5227

    Lb9a7_building_loop:

#b9a7

#5227

1

12

    e5

        push hl

#b9a8

#5228

2

14

    cb 7e

            bit 7, (hl)  ; check if the building is already destroyed.

#b9aa

#522a

2

13/8

    20 31

            jr nz, Lb9dd_skip_building

#b9ac

#522c

1

7

    2b

            dec hl

#b9ad

#522d

1

5

    79

            ld a, c

#b9ae

#522e

2

8

    fe 04

            cp N_WARBASES

#b9b0

#5230

            ; Calculate the distance in the y axis between robot and building.

#b9b0

#5230

3

21

    fd 7e 04

            ld a, (iy + ROBOT_STRUCT_Y)

#b9b3

#5233

2

13/8

    30 02

            jr nc, Lb9b7_not_a_warbase

#b9b5

#5235

2

8

    c6 04

            add a, 4

#b9b7

#5237

    Lb9b7_not_a_warbase:

#b9b7

#5237

1

5

    3c

            inc a

#b9b8

#5238

1

8

    96

            sub (hl)

#b9b9

#5239

            ; "a" now has the difference in the y axis, now calculate the absolute value:

#b9b9

#5239

3

11

    f2 be b9

            jp p, Lb9be_positive_difference

#b9bc

#523c

2

10

    ed 44

            neg

#b9be

#523e

    Lb9be_positive_difference:

#b9be

#523e

1

5

    47

            ld b, a  ; store the difference in y.

#b9bf

#523f

1

5

    ba

            cp d

#b9c0

#5240

2

13/8

    30 1b

            jr nc, Lb9dd_skip_building  ; building is too far

#b9c2

#5242

            ; calculate the distance in the x axis:

#b9c2

#5242

1

12

    d5

            push de

#b9c3

#5243

1

7

    2b

                dec hl

#b9c4

#5244

1

8

    56

                ld d, (hl)

#b9c5

#5245

1

7

    2b

                dec hl

#b9c6

#5246

1

8

    5e

                ld e, (hl)  ; building x

#b9c7

#5247

3

21

    fd 6e 02

                ld l, (iy + ROBOT_STRUCT_X)

#b9ca

#524a

3

21

    fd 66 03

                ld h, (iy + ROBOT_STRUCT_X + 1)  ; robot x

#b9cd

#524d

3

18

    cd ca b3

                call Lb3ca_distance_from_hl_to_de

#b9d0

#5250

1

11

    d1

            pop de

#b9d1

#5251

1

5

    7c

            ld a, h

#b9d2

#5252

1

5

    b7

            or a

#b9d3

#5253

2

13/8

    20 08

            jr nz, Lb9dd_skip_building  ; too far

#b9d5

#5255

1

5

    7d

            ld a, l

#b9d6

#5256

1

5

    ba

            cp d

#b9d7

#5257

2

13/8

    30 04

            jr nc, Lb9dd_skip_building  ; too far

#b9d9

#5259

1

5

    80

            add a, b

#b9da

#525a

1

5

    bb

            cp e  ; check if the sum of distances is larger than 10

#b9db

#525b

2

13/8

    38 15

            jr c, Lb9f2_building_in_range_of_nuclear_bomb

#b9dd

#525d

    Lb9dd_skip_building:

#b9dd

#525d

1

11

    e1

        pop hl

#b9de

#525e

        ; next building

#b9de

#525e

2

8

    3e 05

        ld a, BUILDING_STRUCT_SIZE

#b9e0

#5260

3

18

    cd 51 d3

        call Ld351_add_hl_a

#b9e3

#5263

1

5

    0c

        inc c

#b9e4

#5264

1

5

    79

        ld a, c

#b9e5

#5265

2

8

    fe 04

        cp 4

#b9e7

#5267

2

13/8

    38 be

        jr c, Lb9a7_building_loop

#b9e9

#5269

3

11

    11 07 05

        ld de, #0507  ; nuclear bomb effect radius for factories (something in between a circle and a

#b9ec

#526c

                      ; square):

#b9ec

#526c

                      ; - maximum distance in each axis of 5

#b9ec

#526c

                      ; - maximum sum of distances in each axis of 7

#b9ec

#526c

2

8

    fe 1c

        cp N_WARBASES + N_FACTORIES

#b9ee

#526e

2

13/8

    38 b7

        jr c, Lb9a7_building_loop

#b9f0

#5270

2

13

    18 10

        jr Lba02_look_for_robots_in_range_of_nuclear_bomb

#b9f2

#5272

#b9f2

#5272

    Lb9f2_building_in_range_of_nuclear_bomb:

#b9f2

#5272

        ; A nuclear bomb will only destroy at most one building. As soon as

#b9f2

#5272

        ; a building to destroy is found, we are done with the above loop:

#b9f2

#5272

1

11

    e1

        pop hl

#b9f3

#5273

1

5

    79

        ld a, c

#b9f4

#5274

2

8

    fe 04

        cp N_WARBASES

#b9f6

#5276

2

13/8

    30 05

        jr nc, Lb9fd_factory

#b9f8

#5278

3

18

    cd f9 bb

        call Lbbf9_destroy_warbase

#b9fb

#527b

2

13

    18 05

        jr Lba02_look_for_robots_in_range_of_nuclear_bomb

#b9fd

#527d

    Lb9fd_factory:

#b9fd

#527d

2

8

    d6 04

        sub N_WARBASES

#b9ff

#527f

3

18

    cd d8 bb

        call Lbbd8_destroy_factory

#ba02

#5282

#ba02

#5282

    Lba02_look_for_robots_in_range_of_nuclear_bomb:

#ba02

#5282

        ; Look for robots nearby to destroy

#ba02

#5282

3

21

    fd 6e 00

        ld l, (iy + ROBOT_STRUCT_MAP_PTR)

#ba05

#5285

3

21

    fd 66 01

        ld h, (iy + ROBOT_STRUCT_MAP_PTR + 1)

#ba08

#5288

2

17

    fd e5

        push iy

#ba0a

#528a

3

11

    11 fc f7

            ld de, -(4 * MAP_LENGTH + 4)

#ba0d

#528d

1

12

    19

            add hl, de  ; subtract (4, 4) to the robot map pointer.

#ba0e

#528e

            ; look for robots in a 9x9 window around the robot

#ba0e

#528e

3

11

    01 09 09

            ld bc, #0909

#ba11

#5291

    Lba11_loop_y:

#ba11

#5291

1

12

    c5

            push bc

#ba12

#5292

1

12

    e5

                push hl

#ba13

#5293

1

5

    7c

                    ld a, h

#ba14

#5294

2

8

    fe df

                    cp #df

#ba16

#5296

2

13/8

    38 49

                    jr c, Lba61_next_y  ; out of map bounds

#ba18

#5298

2

8

    fe fd

                    cp #fd

#ba1a

#529a

2

13/8

    30 45

                    jr nc, Lba61_next_y  ; out of map bounds

#ba1c

#529c

1

5

    79

                    ld a, c

#ba1d

#529d

2

8

    fe 01

                    cp 1

#ba1f

#529f

2

13/8

    28 0c

                    jr z, Lba2d_double_x_increment

#ba21

#52a1

2

8

    fe 02

                    cp 2

#ba23

#52a3

2

13/8

    28 0b

                    jr z, Lba30_x_increment

#ba25

#52a5

2

8

    fe 08

                    cp 8

#ba27

#52a7

2

13/8

    28 07

                    jr z, Lba30_x_increment

#ba29

#52a9

2

8

    fe 09

                    cp 9

#ba2b

#52ab

2

13/8

    20 06

                    jr nz, Lba33_loop_x

#ba2d

#52ad

    Lba2d_double_x_increment:

#ba2d

#52ad

1

7

    23

                    inc hl

#ba2e

#52ae

1

5

    05

                    dec b

#ba2f

#52af

1

5

    05

                    dec b

#ba30

#52b0

    Lba30_x_increment:

#ba30

#52b0

1

7

    23

                    inc hl

#ba31

#52b1

1

5

    05

                    dec b

#ba32

#52b2

1

5

    05

                    dec b

#ba33

#52b3

    Lba33_loop_x:

#ba33

#52b3

1

12

    c5

                    push bc

#ba34

#52b4

1

8

    7e

                        ld a, (hl)

#ba35

#52b5

2

10

    cb 77

                        bit 6, a

#ba37

#52b7

2

13/8

    28 0b

                        jr z, Lba44_robots_handled

#ba39

#52b9

3

18

    cd d8 cd

                        call Lcdd8_get_robot_at_ptr

#ba3c

#52bc

2

13/8

    20 06

                        jr nz, Lba44_robots_handled

#ba3e

#52be

4

21

    fd 36 01 00

                        ld (iy + ROBOT_STRUCT_MAP_PTR + 1), 0  ; mark robot as destroyed

#ba42

#52c2

2

17

    cb b6

                        res 6, (hl)  ; remove from map

#ba44

#52c4

    Lba44_robots_handled:

#ba44

#52c4

                        ; Destroy map elements

#ba44

#52c4

1

8

    7e

                        ld a, (hl)

#ba45

#52c5

2

10

    cb 6f

                        bit 5, a

#ba47

#52c7

2

13/8

    20 14

                        jr nz, Lba5d_next_x

#ba49

#52c9

2

8

    e6 1f

                        and #1f

#ba4b

#52cb

2

8

    fe 11

                        cp 17  ; do not destroy terrain

#ba4d

#52cd

2

13/8

    38 0e

                        jr c, Lba5d_next_x

#ba4f

#52cf

2

8

    fe 15

                        cp 21

#ba51

#52d1

2

13/8

    30 0a

                        jr nc, Lba5d_next_x  ; do not destroy the fences that mark the end of the map

#ba53

#52d3

                                             ; in each end.

#ba53

#52d3

3

18

    cd 58 d3

                        call Ld358_random

#ba56

#52d6

2

8

    e6 01

                        and 1

#ba58

#52d8

2

8

    c6 06

                        add a, 6  ; pick a random piece of debris

#ba5a

#52da

3

18

    cd 91 bd

                        call Lbd91_add_element_to_map

#ba5d

#52dd

    Lba5d_next_x:

#ba5d

#52dd

1

11

    c1

                    pop bc

#ba5e

#52de

1

7

    23

                    inc hl

#ba5f

#52df

2

14/9

    10 d2

                    djnz Lba33_loop_x

#ba61

#52e1

    Lba61_next_y:

#ba61

#52e1

1

11

    e1

                pop hl

#ba62

#52e2

1

5

    24

                inc h  ; y+= 1

#ba63

#52e3

1

5

    24

                inc h

#ba64

#52e4

1

11

    c1

            pop bc

#ba65

#52e5

1

5

    0d

            dec c

#ba66

#52e6

2

13/8

    20 a9

            jr nz, Lba11_loop_y

#ba68

#52e8

              ; mark the player in the map and redraw

#ba68

#52e8

3

18

    cd a0 cc

            call Lcca0_compute_player_map_ptr

#ba6b

#52eb

2

17

    cb fe

            set 7, (hl)

#ba6d

#52ed

3

18

    cd bd cc

            call Lccbd_redraw_game_area

#ba70

#52f0

2

16

    fd e1

        pop iy

#ba72

#52f2

4

21

    fd 36 01 00

        ld (iy + ROBOT_STRUCT_MAP_PTR + 1), 0  ; destroy the robot that triggered the nuclear bomb

#ba76

#52f6

3

18

    cd 87 ba

        call Lba87_nuclear_bomb_visual_effect

#ba79

#52f9

2

8

    3e 01

        ld a, 1

#ba7b

#52fb

3

14

    32 52 fd

        ld (Lfd52_update_radar_buffer_signal), a

#ba7e

#52fe

3

18

    cd 40 bb

        call Lbb40_count_robots

#ba81

#5301

3

18

    cd 09 bb

        call Lbb09_update_players_warbase_and_factory_counts

#ba84

#5304

3

11

    c3 93 d2

        jp Ld293_update_stats_in_right_hud

#ba87

#5307

#ba87

#5307

#ba87

#5307

    ; --------------------------------

#ba87

#5307

    ; Nuclear bomb visual and sound effect.

#ba87

#5307

    ; Basically pick random "paper" colors for the game area and keep

#ba87

#5307

    ; changing them, while producing noise in the background.

#ba87

#5307

    Lba87_nuclear_bomb_visual_effect:

#ba87

#5307

        ; Store the original screen attributes to the L5b00 buffer.

#ba87

#5307

3

11

    11 00 5b

        ld de, L5b00

#ba8a

#530a

3

11

    21 21 58

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0021  ; beginning of the game-play area.

#ba8d

#530d

3

11

    01 14 14

        ld bc, #1414  ; 20, 20

#ba90

#5310

    Lba90_loop_y:

#ba90

#5310

1

12

    c5

        push bc

#ba91

#5311

    Lba91_loop_x:

#ba91

#5311

2

18

    ed a0

            ldi

#ba93

#5313

1

5

    0c

            inc c

#ba94

#5314

2

14/9

    10 fb

            djnz Lba91_loop_x

#ba96

#5316

2

8

    3e 0c

            ld a, 12

#ba98

#5318

3

18

    cd 51 d3

            call Ld351_add_hl_a

#ba9b

#531b

1

11

    c1

        pop bc

#ba9c

#531c

1

5

    0d

        dec c

#ba9d

#531d

2

13/8

    20 f1

        jr nz, Lba90_loop_y

#ba9f

#531f

#ba9f

#531f

        ; Visual and sound effect

#ba9f

#531f

3

11

    01 01 f4

        ld bc, #f401

#baa2

#5322

    Lbaa2_nuclear_bomb_visual_effect_loop:

#baa2

#5322

3

18

    cd ee ba

        call Lbaee_nuclear_explosion_sfx

#baa5

#5325

1

12

    c5

        push bc

#baa6

#5326

3

11

    21 21 58

            ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0021  ; beginning of the game-play area.

#baa9

#5329

3

11

    01 14 14

            ld bc, #1414  ; 20, 20

#baac

#532c

    Lbaac_random_color_loop:

#baac

#532c

3

18

    cd 58 d3

            call Ld358_random

#baaf

#532f

2

8

    e6 38

            and #38  ; random number of the form 8 * [0 - 7]  ; random attribute with black ink,

#bab1

#5331

                     ; basically.

#bab1

#5331

2

8

    fe 10

            cp #10

#bab3

#5333

2

13/8

    38 f7

            jr c, Lbaac_random_color_loop  ; do not allow black on black or black on blue.

#bab5

#5335

1

5

    bb

            cp e

#bab6

#5336

2

13/8

    28 f4

            jr z, Lbaac_random_color_loop  ; do not allow the same color as before.

#bab8

#5338

1

5

    5f

            ld e, a

#bab9

#5339

            ; add the new random paper color to all the game area:

#bab9

#5339

    Lbab9_loop_y:

#bab9

#5339

1

12

    c5

            push bc

#baba

#533a

    Lbaba_loop_x:

#baba

#533a

1

8

    7e

                ld a, (hl)

#babb

#533b

2

8

    e6 38

                and #38

#babd

#533d

2

13/8

    28 05

                jr z, Lbac4_skip  ; do not change the black on black areas (sky).

#babf

#533f

1

8

    7e

                ld a, (hl)

#bac0

#5340

2

8

    e6 c7

                and #c7  ; leave ink / brightness the same.

#bac2

#5342

1

5

    b3

                or e  ; add the new paper color.

#bac3

#5343

1

8

    77

                ld (hl), a

#bac4

#5344

    Lbac4_skip:

#bac4

#5344

1

7

    23

                inc hl

#bac5

#5345

2

14/9

    10 f3

                djnz Lbaba_loop_x

#bac7

#5347

2

8

    3e 0c

                ld a, 12

#bac9

#5349

3

18

    cd 51 d3

                call Ld351_add_hl_a

#bacc

#534c

1

11

    c1

            pop bc

#bacd

#534d

1

5

    0d

            dec c

#bace

#534e

2

13/8

    20 e9

            jr nz, Lbab9_loop_y

#bad0

#5350

1

11

    c1

        pop bc

#bad1

#5351

2

14/9

    10 cf

        djnz Lbaa2_nuclear_bomb_visual_effect_loop

#bad3

#5353

#bad3

#5353

        ; Restore the original screen attributes from the L5b00 buffer.

#bad3

#5353

3

11

    21 00 5b

        ld hl, L5b00

#bad6

#5356

3

11

    11 21 58

        ld de, L5800_VIDEOMEM_ATTRIBUTES + #0021

#bad9

#5359

3

11

    01 14 14

        ld bc, #1414  ; 20, 20

#badc

#535c

    Lbadc_loop_y:

#badc

#535c

1

12

    c5

        push bc

#badd

#535d

    Lbadd_loop_x:

#badd

#535d

2

18

    ed a0

            ldi

#badf

#535f

1

5

    0c

            inc c

#bae0

#5360

2

14/9

    10 fb

            djnz Lbadd_loop_x

#bae2

#5362

2

8

    3e 0c

            ld a, 12

#bae4

#5364

1

5

    83

            add a, e

#bae5

#5365

1

5

    5f

            ld e, a

#bae6

#5366

2

13/8

    30 01

            jr nc, Lbae9_continue

#bae8

#5368

1

5

    14

            inc d

#bae9

#5369

    Lbae9_continue:

#bae9

#5369

1

11

    c1

        pop bc

#baea

#536a

1

5

    0d

        dec c

#baeb

#536b

2

13/8

    20 ef

        jr nz, Lbadc_loop_y

#baed

#536d

1

11

    c9

        ret

#baee

#536e

#baee

#536e

#baee

#536e

    ; --------------------------------

#baee

#536e

    ; Produces part of the sfx of the nuclear explosion.

#baee

#536e

    ; This function is called many times in a loop (above), and the

#baee

#536e

    ; combination of all calls, produces the nuclear explosion sound

#baee

#536e

    ; effect.

#baee

#536e

    ; Input:

#baee

#536e

    ; - c: wave period.

#baee

#536e

    ; - b: number of bytes to read to generate noise.

#baee

#536e

    Lbaee_nuclear_explosion_sfx:

#baee

#536e

1

12

    c5

        push bc

#baef

#536f

3

11

    21 90 00

            ld hl, 144

#baf2

#5372

    Lbaf2_outer_loop:

#baf2

#5372

1

12

    c5

            push bc

#baf3

#5373

                ; read a value from some position in the ZX Spectrum BIOS (used to

#baf3

#5373

                ; get some semi-random values to produce noise):

#baf3

#5373

1

8

    7e

                ld a, (hl)

#baf4

#5374

2

8

    e6 10

                and 16

#baf6

#5376

2

12

    d3 fe

                out (ULA_PORT), a  ; change MIC/EAR state (to produce sound).

#baf8

#5378

1

7

    23

                inc hl

#baf9

#5379

                ; insert some delay before we change the wave again:

#baf9

#5379

    Lbaf9_inner_loop:

#baf9

#5379

1

5

    0d

                dec c

#bafa

#537a

1

5

    00

                nop

#bafb

#537b

1

5

    00

                nop

#bafc

#537c

2

13/8

    20 fb

                jr nz, Lbaf9_inner_loop

#bafe

#537e

1

11

    c1

            pop bc

#baff

#537f

2

14/9

    10 f1

            djnz Lbaf2_outer_loop

#bb01

#5381

1

11

    c1

        pop bc

#bb02

#5382

1

5

    05

        dec b

#bb03

#5383

1

5

    05

        dec b

#bb04

#5384

1

5

    05

        dec b

#bb05

#5385

1

5

    0c

        inc c

#bb06

#5386

1

5

    0c

        inc c

#bb07

#5387

1

5

    0c

        inc c

#bb08

#5388

1

11

    c9

        ret

#bb09

#5389

#bb09

#5389

#bb09

#5389

    ; --------------------------------

#bb09

#5389

    ; Clears the factory/warbase counters, and recomputes it from scratch.

#bb09

#5389

    Lbb09_update_players_warbase_and_factory_counts:

#bb09

#5389

        ; clear warbase/factory counts:

#bb09

#5389

3

11

    21 3a fd

        ld hl, Lfd3a_player1_base_factory_counts

#bb0c

#538c

2

8

    06 07

        ld b, 7

#bb0e

#538e

    Lbb0e_clear_player1_loop:

#bb0e

#538e

2

11

    36 00

        ld (hl), 0

#bb10

#5390

1

7

    23

        inc hl

#bb11

#5391

2

14/9

    10 fb

        djnz Lbb0e_clear_player1_loop

#bb13

#5393

1

7

    23

        inc hl  ; skip robot count

#bb14

#5394

2

8

    06 07

        ld b, 7

#bb16

#5396

    Lbb16_clear_player2_loop:

#bb16

#5396

2

11

    36 00

        ld (hl), 0

#bb18

#5398

1

7

    23

        inc hl

#bb19

#5399

2

14/9

    10 fb

        djnz Lbb16_clear_player2_loop

#bb1b

#539b

3

11

    11 73 fd

        ld de, Lfd70_warbases + BUILDING_STRUCT_TYPE

#bb1e

#539e

2

8

    06 1c

        ld b, N_WARBASES + N_FACTORIES

#bb20

#53a0

    Lbb20:

#bb20

#53a0

1

8

    1a

        ld a, (de)

#bb21

#53a1

1

5

    b7

        or a

#bb22

#53a2

3

11

    fa 39 bb

        jp m, Lbb39_skip

#bb25

#53a5

3

11

    21 3a fd

        ld hl, Lfd3a_player1_base_factory_counts

#bb28

#53a8

2

10

    cb 77

        bit 6, a  ; bit 6 indicates it belongs to player 1

#bb2a

#53aa

2

13/8

    20 07

        jr nz, Lbb33_increment_counter

#bb2c

#53ac

3

11

    21 42 fd

        ld hl, Lfd42_player2_base_factory_counts

#bb2f

#53af

2

10

    cb 6f

        bit 5, a  ; bit 5 indicates it belongs to player 2 (AI)

#bb31

#53b1

2

13/8

    28 06

        jr z, Lbb39_skip

#bb33

#53b3

    Lbb33_increment_counter:

#bb33

#53b3

2

8

    e6 07

        and 7  ; ignore the owners, and just keep the type

#bb35

#53b5

3

18

    cd 51 d3

        call Ld351_add_hl_a

#bb38

#53b8

1

12

    34

        inc (hl)  ; increment the count

#bb39

#53b9

    Lbb39_skip:

#bb39

#53b9

1

5

    7b

        ld a, e

#bb3a

#53ba

2

8

    c6 05

        add a, 5

#bb3c

#53bc

1

5

    5f

        ld e, a

#bb3d

#53bd

2

14/9

    10 e1

        djnz Lbb20

#bb3f

#53bf

1

11

    c9

        ret

#bb40

#53c0

#bb40

#53c0

#bb40

#53c0

    ; --------------------------------

#bb40

#53c0

    ; Counts the number of robots of each player and stores it in "Lfd41_player1_robot_count" and

#bb40

#53c0

    ; "Lfd49_player2_robot_count"

#bb40

#53c0

    Lbb40_count_robots:

#bb40

#53c0

3

11

    21 01 da

        ld hl, Lda00_player1_robots + 1

#bb43

#53c3

3

18

    cd 50 bb

        call Lbb50_count_player_robots

#bb46

#53c6

3

14

    32 41 fd

        ld (Lfd41_player1_robot_count), a

#bb49

#53c9

3

18

    cd 50 bb

        call Lbb50_count_player_robots

#bb4c

#53cc

3

14

    32 49 fd

        ld (Lfd49_player2_robot_count), a

#bb4f

#53cf

1

11

    c9

        ret

#bb50

#53d0

#bb50

#53d0

#bb50

#53d0

    ; --------------------------------

#bb50

#53d0

    ; Counts the number of robots a player has

#bb50

#53d0

    ; Input:

#bb50

#53d0

    ; - hl: pointer to the table of robots of a given player (offset by one byte)

#bb50

#53d0

    ; Returns:

#bb50

#53d0

    ; - a: # robots

#bb50

#53d0

    Lbb50_count_player_robots:

#bb50

#53d0

2

8

    06 18

        ld b, MAX_ROBOTS_PER_PLAYER

#bb52

#53d2

2

8

    0e 00

        ld c, 0

#bb54

#53d4

3

11

    11 10 00

        ld de, 16

#bb57

#53d7

    Lbb57_count_player_robots_loop:

#bb57

#53d7

1

8

    7e

        ld a, (hl)

#bb58

#53d8

1

5

    b7

        or a

#bb59

#53d9

2

13/8

    28 01

        jr z, Lbb5c_no_robot

#bb5b

#53db

1

5

    0c

        inc c

#bb5c

#53dc

    Lbb5c_no_robot:

#bb5c

#53dc

1

12

    19

        add hl, de

#bb5d

#53dd

2

14/9

    10 f8

        djnz Lbb57_count_player_robots_loop

#bb5f

#53df

1

5

    79

        ld a, c

#bb60

#53e0

1

11

    c9

        ret

#bb61

#53e1

#bb61

#53e1

#bb61

#53e1

    ; --------------------------------

#bb61

#53e1

    ; Gets factory # "a", removes any records of being owned by a previous player, and assigns it to

#bb61

#53e1

    ; player "b".

#bb61

#53e1

    ; Input:

#bb61

#53e1

    ; - a: factory index

#bb61

#53e1

    ; - b: owner

#bb61

#53e1

    Lbb61_assign_factory_to_player:

#bb61

#53e1

3

11

    21 87 fd

        ld hl, Lfd84_factories + BUILDING_STRUCT_TYPE

#bb64

#53e4

3

18

    cd b9 bb

        call Lbbb9_mark_ath_building_and_get_ptr

#bb67

#53e7

1

5

    25

        dec h

#bb68

#53e8

1

5

    25

        dec h

#bb69

#53e9

1

5

    25

        dec h

#bb6a

#53ea

1

5

    25

        dec h

#bb6b

#53eb

1

7

    23

        inc hl

#bb6c

#53ec

1

7

    23

        inc hl

#bb6d

#53ed

3

18

    cd 5d bc

        call Lbc5d_remove_decoration  ; remove a potential enemy flag

#bb70

#53f0

1

7

    2b

        dec hl

#bb71

#53f1

1

7

    2b

        dec hl

#bb72

#53f2

1

7

    2b

        dec hl

#bb73

#53f3

1

7

    2b

        dec hl

#bb74

#53f4

3

18

    cd 5d bc

        call Lbc5d_remove_decoration  ; remove a potential player flag

#bb77

#53f7

1

5

    78

        ld a, b  ; owner

#bb78

#53f8

1

5

    b7

        or a

#bb79

#53f9

2

13/8

    28 04

        jr z, Lbb7f_assign_to_player

#bb7b

#53fb

        ; the enemy sets the flag in a different position than the player

#bb7b

#53fb

1

7

    23

        inc hl

#bb7c

#53fc

1

7

    23

        inc hl

#bb7d

#53fd

1

7

    23

        inc hl

#bb7e

#53fe

1

7

    23

        inc hl

#bb7f

#53ff

    Lbb7f_assign_to_player:

#bb7f

#53ff

2

8

    c6 07

        add a, 7  ; add a flag

#bb81

#5401

1

5

    4f

        ld c, a

#bb82

#5402

3

18

    cd 43 bc

        call Lbc43_add_decoration_to_map  ; Potential optimization: tail recursion.

#bb85

#5405

1

11

    c9

        ret

#bb86

#5406

#bb86

#5406

#bb86

#5406

    ; --------------------------------

#bb86

#5406

    ; Input:

#bb86

#5406

    ; - a: warbase index

#bb86

#5406

    ; - b: player to assign it to

#bb86

#5406

    Lbb86_assign_warbase_to_player:

#bb86

#5406

3

11

    21 73 fd

        ld hl, Lfd70_warbases + BUILDING_STRUCT_TYPE

#bb89

#5409

3

18

    cd b9 bb

        call Lbbb9_mark_ath_building_and_get_ptr

#bb8c

#540c

1

5

    7c

        ld a, h

#bb8d

#540d

2

8

    d6 08

        sub 8

#bb8f

#540f

1

5

    67

        ld h, a

#bb90

#5410

3

18

    cd 5d bc

        call Lbc5d_remove_decoration

#bb93

#5413

1

5

    2d

        dec l

#bb94

#5414

1

5

    2d

        dec l

#bb95

#5415

1

5

    2d

        dec l

#bb96

#5416

1

5

    2d

        dec l

#bb97

#5417

3

18

    cd 5d bc

        call Lbc5d_remove_decoration

#bb9a

#541a

1

5

    7d

        ld a, l

#bb9b

#541b

2

8

    c6 08

        add a, 8

#bb9d

#541d

1

5

    6f

        ld l, a

#bb9e

#541e

3

18

    cd 5d bc

        call Lbc5d_remove_decoration

#bba1

#5421

2

8

    0e 08

        ld c, 8

#bba3

#5423

1

5

    78

        ld a, b

#bba4

#5424

1

5

    b7

        or a

#bba5

#5425

3

11

    c2 43 bc

        jp nz, Lbc43_add_decoration_to_map

#bba8

#5428

1

5

    2d

        dec l

#bba9

#5429

1

5

    2d

        dec l

#bbaa

#542a

1

5

    2d

        dec l

#bbab

#542b

1

5

    2d

        dec l

#bbac

#542c

1

5

    4f

        ld c, a

#bbad

#542d

3

18

    cd 43 bc

        call Lbc43_add_decoration_to_map

#bbb0

#5430

1

5

    2d

        dec l

#bbb1

#5431

1

5

    2d

        dec l

#bbb2

#5432

1

5

    2d

        dec l

#bbb3

#5433

1

5

    2d

        dec l

#bbb4

#5434

2

8

    0e 07

        ld c, 7

#bbb6

#5436

3

11

    c3 43 bc

        jp Lbc43_add_decoration_to_map

#bbb9

#5439

#bbb9

#5439

#bbb9

#5439

    ; --------------------------------

#bbb9

#5439

    ; Marks whether the a-th warbase/factory belongs to player 1 or 2, and returns

#bbb9

#5439

    ; its pointer in the map.

#bbb9

#5439

    ; Input:

#bbb9

#5439

    ; - a: index of warbase/factory

#bbb9

#5439

    ; - hl: ptr to the beginning of the warbase/factory + 3

#bbb9

#5439

    ; - b: owner

#bbb9

#5439

    Lbbb9_mark_ath_building_and_get_ptr:

#bbb9

#5439

1

5

    4f

        ld c, a

#bbba

#543a

1

5

    87

        add a, a

#bbbb

#543b

1

5

    87

        add a, a

#bbbc

#543c

1

5

    81

        add a, c

#bbbd

#543d

3

18

    cd 51 d3

        call Ld351_add_hl_a  ; hl = hl + a * 5

#bbc0

#5440

1

5

    78

        ld a, b

#bbc1

#5441

1

5

    b7

        or a

#bbc2

#5442

2

8

    3e 40

        ld a, #40  ; if player == 0, mark bit 6

#bbc4

#5444

2

13/8

    28 01

        jr z, Lbbc7_neutral

#bbc6

#5446

1

5

    0f

        rrca  ; if player != 0, mark bit 5 instead

#bbc7

#5447

    Lbbc7_neutral:

#bbc7

#5447

1

5

    4f

        ld c, a

#bbc8

#5448

1

8

    7e

        ld a, (hl)

#bbc9

#5449

2

8

    e6 1f

        and 31

#bbcb

#544b

1

5

    b1

        or c

#bbcc

#544c

1

8

    77

        ld (hl), a  ; update the location in the map with the neutral/occupied mark

#bbcd

#544d

    Lbbcd_get_map_ptr_of_warbase:

#bbcd

#544d

1

7

    2b

        dec hl

#bbce

#544e

1

8

    4e

        ld c, (hl)

#bbcf

#544f

1

7

    2b

        dec hl

#bbd0

#5450

1

8

    7e

        ld a, (hl)

#bbd1

#5451

1

7

    2b

        dec hl

#bbd2

#5452

1

8

    6e

        ld l, (hl)

#bbd3

#5453

1

5

    67

        ld h, a

#bbd4

#5454

1

5

    79

        ld a, c

#bbd5

#5455

3

11

    c3 a6 cc

        jp Lcca6_compute_map_ptr

#bbd8

#5458

#bbd8

#5458

#bbd8

#5458

    ; --------------------------------

#bbd8

#5458

    ; Destroy a factory and replace it with debris.

#bbd8

#5458

    ; Input:

#bbd8

#5458

    ; - a: factory index.

#bbd8

#5458

    Lbbd8_destroy_factory:

#bbd8

#5458

3

11

    21 87 fd

        ld hl, Lfd84_factories + BUILDING_STRUCT_TYPE

#bbdb

#545b

3

18

    cd 1c bc

        call Lbc1c_mark_building_as_destroyed_and_get_map_ptr

#bbde

#545e

1

12

    e5

        push hl

#bbdf

#545f

            ; Remove the potential flags (player/enemy) and the factory type decoration:

#bbdf

#545f

1

5

    25

            dec h

#bbe0

#5460

1

5

    25

            dec h

#bbe1

#5461

1

5

    25

            dec h

#bbe2

#5462

1

5

    25

            dec h

#bbe3

#5463

1

7

    23

            inc hl

#bbe4

#5464

1

7

    23

            inc hl

#bbe5

#5465

3

18

    cd 5d bc

            call Lbc5d_remove_decoration

#bbe8

#5468

1

7

    2b

            dec hl

#bbe9

#5469

1

7

    2b

            dec hl

#bbea

#546a

3

18

    cd 5d bc

            call Lbc5d_remove_decoration

#bbed

#546d

1

7

    2b

            dec hl

#bbee

#546e

1

7

    2b

            dec hl

#bbef

#546f

3

18

    cd 5d bc

            call Lbc5d_remove_decoration

#bbf2

#5472

1

11

    e1

        pop hl

#bbf3

#5473

3

11

    11 e2 bf

        ld de, Lbfe2_factory

#bbf6

#5476

3

11

    c3 27 bc

        jp Lbc27_replace_building_by_debris

#bbf9

#5479

#bbf9

#5479

#bbf9

#5479

    ; --------------------------------

#bbf9

#5479

    ; Destroy a warbase and replace it with debris.

#bbf9

#5479

    ; Input:

#bbf9

#5479

    ; - a: warbase index.

#bbf9

#5479

    Lbbf9_destroy_warbase:

#bbf9

#5479

3

11

    21 73 fd

        ld hl, Lfd70_warbases + BUILDING_STRUCT_TYPE

#bbfc

#547c

3

18

    cd 1c bc

        call Lbc1c_mark_building_as_destroyed_and_get_map_ptr

#bbff

#547f

1

12

    e5

        push hl

#bc00

#5480

            ; Remove the potential flags (player/enemy) and the warbase "H" decoration:

#bc00

#5480

1

5

    7c

            ld a, h

#bc01

#5481

2

8

    d6 08

            sub 8

#bc03

#5483

1

5

    67

            ld h, a

#bc04

#5484

3

18

    cd 5d bc

            call Lbc5d_remove_decoration

#bc07

#5487

1

5

    2d

            dec l

#bc08

#5488

1

5

    2d

            dec l

#bc09

#5489

1

5

    2d

            dec l

#bc0a

#548a

1

5

    2d

            dec l

#bc0b

#548b

3

18

    cd 5d bc

            call Lbc5d_remove_decoration

#bc0e

#548e

1

5

    7d

            ld a, l

#bc0f

#548f

2

8

    c6 08

            add a, 8

#bc11

#5491

1

5

    6f

            ld l, a

#bc12

#5492

3

18

    cd 5d bc

            call Lbc5d_remove_decoration

#bc15

#5495

1

11

    e1

        pop hl

#bc16

#5496

3

11

    11 b2 bf

        ld de, Lbfb2_warbase

#bc19

#5499

3

11

    c3 27 bc

        jp Lbc27_replace_building_by_debris

#bc1c

#549c

#bc1c

#549c

#bc1c

#549c

    ; --------------------------------

#bc1c

#549c

    ; Marks a given warbase as destroyed, and returns the map pointer where it is located.

#bc1c

#549c

    ; Input:

#bc1c

#549c

    ; - hl: warbases array ptr + 3

#bc1c

#549c

    ; - a: warbase index

#bc1c

#549c

    Lbc1c_mark_building_as_destroyed_and_get_map_ptr:

#bc1c

#549c

1

5

    4f

        ld c, a

#bc1d

#549d

1

5

    87

        add a, a

#bc1e

#549e

1

5

    87

        add a, a

#bc1f

#549f

1

5

    81

        add a, c  ; a *= BUILDING_STRING_SIZE

#bc20

#54a0

3

18

    cd 51 d3

        call Ld351_add_hl_a

#bc23

#54a3

2

11

    36 80

        ld (hl), #80  ; mark warbase as destroyed

#bc25

#54a5

2

13

    18 a6

        jr Lbbcd_get_map_ptr_of_warbase

#bc27

#54a7

#bc27

#54a7

#bc27

#54a7

    ; --------------------------------

#bc27

#54a7

    ; Replace a building by debris. This is used when factories/warbases are destroyed.

#bc27

#54a7

    ; Input:

#bc27

#54a7

    ; - hl: map pointer of the building.

#bc27

#54a7

    ; - de: pointer to a building definition.

#bc27

#54a7

    Lbc27_replace_building_by_debris:

#bc27

#54a7

1

8

    1a

        ld a, (de)

#bc28

#54a8

1

5

    b7

        or a

#bc29

#54a9

2

13/8

    28 0a

        jr z, Lbc35

#bc2b

#54ab

3

18

    cd 58 d3

        call Ld358_random  ; select a random debris graphic

#bc2e

#54ae

2

8

    e6 01

        and 1

#bc30

#54b0

2

8

    c6 06

        add a, 6

#bc32

#54b2

3

18

    cd 91 bd

        call Lbd91_add_element_to_map

#bc35

#54b5

    Lbc35:

#bc35

#54b5

        ; See if the building has more parts. Each part is a 3 byte block: type, x offset, y offset. If

#bc35

#54b5

        ; the offsets are both 0, it means there are no more parts.

#bc35

#54b5

1

7

    13

        inc de

#bc36

#54b6

1

8

    1a

        ld a, (de)

#bc37

#54b7

1

5

    4f

        ld c, a

#bc38

#54b8

1

7

    13

        inc de

#bc39

#54b9

1

8

    1a

        ld a, (de)

#bc3a

#54ba

1

5

    47

        ld b, a

#bc3b

#54bb

1

7

    13

        inc de

#bc3c

#54bc

1

5

    b1

        or c

#bc3d

#54bd

1

12/6

    c8

        ret z  ; The offsets are zero, there are no more parts.

#bc3e

#54be

3

18

    cd 7f bd

        call Lbd7f_add_map_ptr_offset

#bc41

#54c1

2

13

    18 e4

        jr Lbc27_replace_building_by_debris

#bc43

#54c3

#bc43

#54c3

#bc43

#54c3

    ; --------------------------------

#bc43

#54c3

    ; Finds an empty spot in the building decoration list, and adds a decoration

#bc43

#54c3

    ; record pointing at position "hl" in the map.

#bc43

#54c3

    ; Input:

#bc43

#54c3

    ; - hl: map ptr

#bc43

#54c3

    ; - c: type

#bc43

#54c3

    Lbc43_add_decoration_to_map:

#bc43

#54c3

3

11

    11 02 ff

        ld de, Lff01_building_decorations + 1

#bc46

#54c6

2

8

    06 38

        ld b, (N_WARBASES + N_FACTORIES) * 2

#bc48

#54c8

    Lbc48_loop:

#bc48

#54c8

1

8

    1a

        ld a, (de)

#bc49

#54c9

1

5

    b7

        or a

#bc4a

#54ca

2

13/8

    28 06

        jr z, Lbc52_empty_spot_found

#bc4c

#54cc

1

7

    13

        inc de

#bc4d

#54cd

1

7

    13

        inc de

#bc4e

#54ce

1

7

    13

        inc de

#bc4f

#54cf

2

14/9

    10 f7

        djnz Lbc48_loop

#bc51

#54d1

1

11

    c9

        ret

#bc52

#54d2

    Lbc52_empty_spot_found:

#bc52

#54d2

1

7

    1b

        dec de

#bc53

#54d3

2

17

    cb f6

        set 6, (hl)  ; mark bit 6 of the map position

#bc55

#54d5

1

5

    eb

        ex de, hl

#bc56

#54d6

1

8

    73

            ld (hl), e  ; map pointer

#bc57

#54d7

1

7

    23

            inc hl

#bc58

#54d8

1

8

    72

            ld (hl), d  ; map pointer

#bc59

#54d9

1

7

    23

            inc hl

#bc5a

#54da

1

8

    71

            ld (hl), c  ; type

#bc5b

#54db

1

5

    eb

        ex de, hl

#bc5c

#54dc

1

11

    c9

        ret

#bc5d

#54dd

#bc5d

#54dd

#bc5d

#54dd

    ; --------------------------------

#bc5d

#54dd

    ; Searches for a building owner record with ptr == hl, and removes it.

#bc5d

#54dd

    ; Input:

#bc5d

#54dd

    ; - hl: map ptr

#bc5d

#54dd

    Lbc5d_remove_decoration:

#bc5d

#54dd

2

17

    fd e5

        push iy

#bc5f

#54df

1

12

    c5

        push bc

#bc60

#54e0

3

18

    cd f5 cd

            call Lcdf5_find_building_decoration_with_ptr

#bc63

#54e3

2

13/8

    20 06

            jr nz, Lbc6b_not_found

#bc65

#54e5

4

21

    fd 36 01 00

            ld (iy + 1), 0  ; removes the record

#bc69

#54e9

2

17

    cb b6

            res 6, (hl)  ; removes the mark from the map

#bc6b

#54eb

    Lbc6b_not_found:

#bc6b

#54eb

1

11

    c1

        pop bc

#bc6c

#54ec

2

16

    fd e1

        pop iy

#bc6e

#54ee

1

11

    c9

        ret

#bc6f

#54ef

#bc6f

#54ef

#bc6f

#54ef

    ; --------------------------------

#bc6f

#54ef

    ; Initializes the map buffer in Ldd00_map and all the warbase/factory/flag records.

#bc6f

#54ef

    Lbc6f_initialize_map:

#bc6f

#54ef

        ; Clear the map:

#bc6f

#54ef

3

11

    21 00 dd

        ld hl, Ldd00_map

#bc72

#54f2

1

5

    54

        ld d, h

#bc73

#54f3

1

5

    5d

        ld e, l

#bc74

#54f4

1

7

    13

        inc de

#bc75

#54f5

3

11

    01 ff 1f

        ld bc, MAP_LENGTH * MAP_WIDTH - 1

#bc78

#54f8

2

11

    36 00

        ld (hl), 0

#bc7a

#54fa

2

23/18

    ed b0

        ldir

#bc7c

#54fc

#bc7c

#54fc

        ; Clear the minimap:

#bc7c

#54fc

3

11

    21 00 d8

        ld hl, Ld800_radar_view1

#bc7f

#54ff

1

5

    54

        ld d, h

#bc80

#5500

1

5

    5d

        ld e, l

#bc81

#5501

1

7

    13

        inc de

#bc82

#5502

3

11

    01 ff 00

        ld bc, 255

#bc85

#5505

2

11

    36 00

        ld (hl), 0

#bc87

#5507

2

23/18

    ed b0

        ldir

#bc89

#5509

#bc89

#5509

3

11

    21 a9 bd

        ld hl, Lbda9_map_elements_part1

#bc8c

#550c

2

8

    16 00

        ld d, 0  ; indicates x < 256

#bc8e

#550e

3

18

    cd d6 bc

        call Lbcd6_add_elements_to_map  ; Write map elements to the map buffer (those with x < 256)

#bc91

#5511

#bc91

#5511

3

11

    21 79 be

        ld hl, Lbe79_map_elements_part2

#bc94

#5514

2

8

    16 01

        ld d, 1  ; indicates x >= 256

#bc96

#5516

3

18

    cd d6 bc

        call Lbcd6_add_elements_to_map  ; Write map elements to the map buffer (those with x >= 256)

#bc99

#5519

#bc99

#5519

4

16

    fd 21 84 fd

        ld iy, Lfd84_factories

#bc9d

#551d

4

16

    dd 21 70 fd

        ld ix, Lfd70_warbases

#bca1

#5521

#bca1

#5521

3

11

    21 46 bf

        ld hl, Lbf46_warbases_factories_part1

#bca4

#5524

2

8

    16 00

        ld d, 0

#bca6

#5526

3

18

    cd f9 bc

        call Lbcf9_add_warbases_and_factories_to_map

#bca9

#5529

#bca9

#5529

3

11

    21 6e bf

        ld hl, Lbf6e_warbases_factories_part2

#bcac

#552c

2

8

    16 01

        ld d, 1

#bcae

#552e

3

18

    cd f9 bc

        call Lbcf9_add_warbases_and_factories_to_map

#bcb1

#5531

#bcb1

#5531

1

5

    af

        xor a

#bcb2

#5532

1

5

    47

        ld b, a

#bcb3

#5533

3

18

    cd 86 bb

        call Lbb86_assign_warbase_to_player  ; warbase 0 to player 1

#bcb6

#5536

2

8

    3e 01

        ld a, 1

#bcb8

#5538

1

5

    47

        ld b, a

#bcb9

#5539

3

18

    cd 86 bb

        call Lbb86_assign_warbase_to_player  ; warbase 1 to player 2

#bcbc

#553c

2

8

    3e 02

        ld a, 2

#bcbe

#553e

2

8

    06 01

        ld b, 1

#bcc0

#5540

3

18

    cd 86 bb

        call Lbb86_assign_warbase_to_player  ; warbase 2 to player 2

#bcc3

#5543

2

8

    3e 03

        ld a, 3

#bcc5

#5545

2

8

    06 01

        ld b, 1

#bcc7

#5547

3

18

    cd 86 bb

        call Lbb86_assign_warbase_to_player  ; warbase 3 to player 2

#bcca

#554a

3

18

    cd 09 bb

        call Lbb09_update_players_warbase_and_factory_counts  ; compute the warbase/factory counts

#bccd

#554d

2

8

    3e 01

        ld a, 1

#bccf

#554f

3

14

    32 52 fd

        ld (Lfd52_update_radar_buffer_signal), a

#bcd2

#5552

3

18

    cd 24 b0

        call Lb024_add_player_to_map_and_update_radar  ; Potential optimization: tail recursion.

#bcd5

#5555

1

11

    c9

        ret

#bcd6

#5556

#bcd6

#5556

#bcd6

#5556

    ; --------------------------------

#bcd6

#5556

    ; Adds a list of map elements to the map buffer.

#bcd6

#5556

    ; Input:

#bcd6

#5556

    ; - d: A 0 or a 1. Indicates whether x coordinates start at 0 or at 256.

#bcd6

#5556

    Lbcd6_add_elements_to_map:

#bcd6

#5556

    Lbcd6_loop:

#bcd6

#5556

1

8

    7e

        ld a, (hl)

#bcd7

#5557

1

5

    b7

        or a

#bcd8

#5558

1

12/6

    c8

        ret z  ; a 0 at the end indicates end of data.

#bcd9

#5559

1

5

    4f

        ld c, a  ; element type

#bcda

#555a

1

7

    23

        inc hl

#bcdb

#555b

1

8

    5e

        ld e, (hl)  ; x

#bcdc

#555c

1

7

    23

        inc hl

#bcdd

#555d

1

8

    7e

        ld a, (hl)  ; y % 256

#bcde

#555e

1

7

    23

        inc hl  ; we have read 3 bytes from the data in: c, e, a.

#bcdf

#555f

1

12

    e5

        push hl

#bce0

#5560

1

12

    d5

        push de

#bce1

#5561

3

11

    21 00 dd

            ld hl, Ldd00_map

#bce4

#5564

1

5

    87

            add a, a

#bce5

#5565

1

5

    84

            add a, h

#bce6

#5566

1

5

    67

            ld h, a

#bce7

#5567

1

12

    19

            add hl, de  ; hl now has the pointer in the map to (e, a + d*256).

#bce8

#5568

1

5

    79

            ld a, c

#bce9

#5569

1

5

    b7

            or a

#bcea

#556a

3

11

    fa f2 bc

            jp m, Lbcf2  ; Those elements with msb set to 1 are complex structures, and are handled

#bced

#556d

                         ; separately.

#bced

#556d

3

18

    cd 91 bd

            call Lbd91_add_element_to_map

#bcf0

#5570

2

13

    18 03

            jr Lbcf5_continue

#bcf2

#5572

    Lbcf2:

#bcf2

#5572

3

18

    cd 61 bd

            call Lbd61_add_complex_structure_to_map

#bcf5

#5575

    Lbcf5_continue:

#bcf5

#5575

1

11

    d1

        pop de

#bcf6

#5576

1

11

    e1

        pop hl

#bcf7

#5577

2

13

    18 dd

        jr Lbcd6_loop

#bcf9

#5579

#bcf9

#5579

#bcf9

#5579

    ; --------------------------------

#bcf9

#5579

    ; Adds warbases and factories to the map.

#bcf9

#5579

    ; - It also adds all the factories to the buildings list (but not the warbases)

#bcf9

#5579

    ; Input:

#bcf9

#5579

    ; - d: 0 if element x < 256, 1 if element x >= 256

#bcf9

#5579

    ; - hl: ptr to the elements to add.

#bcf9

#5579

    ; - ix: ptr to the factory list

#bcf9

#5579

    ; - iy: ptr to the warbase list

#bcf9

#5579

    Lbcf9_add_warbases_and_factories_to_map:

#bcf9

#5579

1

8

    7e

        ld a, (hl)

#bcfa

#557a

1

5

    b7

        or a

#bcfb

#557b

1

12/6

    f8

        ret m  ; a 1 in the most significant bit indicates termination

#bcfc

#557c

1

5

    4f

        ld c, a  ; type

#bcfd

#557d

1

7

    23

        inc hl

#bcfe

#557e

1

8

    5e

        ld e, (hl)  ; x (the most significant byte of x is passed as argument in d)

#bcff

#557f

1

7

    23

        inc hl

#bd00

#5580

1

8

    7e

        ld a, (hl)

#bd01

#5581

1

5

    47

        ld b, a  ; y

#bd02

#5582

1

7

    23

        inc hl

#bd03

#5583

1

12

    e5

        push hl

#bd04

#5584

1

12

    d5

        push de

#bd05

#5585

3

11

    21 00 dd

            ld hl, Ldd00_map

#bd08

#5588

1

5

    87

            add a, a

#bd09

#5589

1

5

    84

            add a, h

#bd0a

#558a

1

5

    67

            ld h, a

#bd0b

#558b

1

12

    19

            add hl, de  ; hl now points to the position in the map corresponding to the x, y,

#bd0c

#558c

                        ; coordinates of the element

#bd0c

#558c

1

5

    79

            ld a, c

#bd0d

#558d

1

5

    b7

            or a

#bd0e

#558e

2

13/8

    28 2e

            jr z, Lbd3e_warbase

#bd10

#5590

3

21

    fd 73 00

            ld (iy + 0), e  ; x

#bd13

#5593

3

21

    fd 72 01

            ld (iy + 1), d  ; x

#bd16

#5596

3

21

    fd 70 02

            ld (iy + 2), b  ; y

#bd19

#5599

3

21

    fd 71 03

            ld (iy + 3), c  ; type

#bd1c

#559c

4

21

    fd 36 04 00

            ld (iy + 4), 0

#bd20

#55a0

2

12

    fd 23

            inc iy

#bd22

#55a2

2

12

    fd 23

            inc iy

#bd24

#55a4

2

12

    fd 23

            inc iy

#bd26

#55a6

2

12

    fd 23

            inc iy

#bd28

#55a8

2

12

    fd 23

            inc iy

#bd2a

#55aa

1

12

    c5

            push bc

#bd2b

#55ab

1

12

    e5

            push hl

#bd2c

#55ac

2

8

    3e 81

                ld a, #81  ; add a factory

#bd2e

#55ae

3

18

    cd 61 bd

                call Lbd61_add_complex_structure_to_map

#bd31

#55b1

1

11

    e1

            pop hl

#bd32

#55b2

1

11

    c1

            pop bc

#bd33

#55b3

1

5

    25

            dec h

#bd34

#55b4

1

5

    25

            dec h

#bd35

#55b5

1

5

    25

            dec h

#bd36

#55b6

1

5

    25

            dec h

#bd37

#55b7

            ; notice c still holds the type here

#bd37

#55b7

3

18

    cd 43 bc

            call Lbc43_add_decoration_to_map

#bd3a

#55ba

1

11

    d1

        pop de

#bd3b

#55bb

1

11

    e1

        pop hl

#bd3c

#55bc

2

13

    18 bb

        jr Lbcf9_add_warbases_and_factories_to_map

#bd3e

#55be

    Lbd3e_warbase:

#bd3e

#55be

3

21

    dd 73 00

            ld (ix + 0), e  ; x

#bd41

#55c1

3

21

    dd 72 01

            ld (ix + 1), d  ; x

#bd44

#55c4

3

21

    dd 70 02

            ld (ix + 2), b  ; y

#bd47

#55c7

3

21

    dd 71 03

            ld (ix + 3), c  ; type

#bd4a

#55ca

4

21

    dd 36 04 00

            ld (ix + 4), 0

#bd4e

#55ce

2

12

    dd 23

            inc ix

#bd50

#55d0

2

12

    dd 23

            inc ix

#bd52

#55d2

2

12

    dd 23

            inc ix

#bd54

#55d4

2

12

    dd 23

            inc ix

#bd56

#55d6

2

12

    dd 23

            inc ix

#bd58

#55d8

2

8

    3e 80

            ld a, #80  ; add a warbase

#bd5a

#55da

3

18

    cd 61 bd

            call Lbd61_add_complex_structure_to_map

#bd5d

#55dd

1

11

    d1

        pop de

#bd5e

#55de

1

11

    e1

        pop hl

#bd5f

#55df

2

13

    18 98

        jr Lbcf9_add_warbases_and_factories_to_map

#bd61

#55e1

#bd61

#55e1

#bd61

#55e1

    ; --------------------------------

#bd61

#55e1

    ; Adds a complex structure to the map buffer.

#bd61

#55e1

    Lbd61_add_complex_structure_to_map:

#bd61

#55e1

1

12

    e5

        push hl

#bd62

#55e2

3

11

    21 9c bf

            ld hl, Lbf9c_map_complex_structure_ptrs

#bd65

#55e5

2

8

    e6 7f

            and #7f  ; remove the msb

#bd67

#55e7

3

18

    cd 48 d3

            call Ld348_get_ptr_from_table

#bd6a

#55ea

1

5

    eb

            ex de, hl

#bd6b

#55eb

1

11

    e1

        pop hl

#bd6c

#55ec

    Lbd6c_loop:

#bd6c

#55ec

1

8

    1a

        ld a, (de)

#bd6d

#55ed

1

5

    b7

        or a  ; element type

#bd6e

#55ee

3

18/11

    c4 91 bd

        call nz, Lbd91_add_element_to_map  ; if the structure is != 0, end.

#bd71

#55f1

1

7

    13

        inc de

#bd72

#55f2

1

8

    1a

        ld a, (de)

#bd73

#55f3

1

5

    4f

        ld c, a  ; x

#bd74

#55f4

1

7

    13

        inc de

#bd75

#55f5

1

8

    1a

        ld a, (de)

#bd76

#55f6

1

5

    47

        ld b, a  ; y

#bd77

#55f7

1

7

    13

        inc de

#bd78

#55f8

1

5

    b1

        or c

#bd79

#55f9

1

12/6

    c8

        ret z  ; if x == y == 0, we are done

#bd7a

#55fa

3

18

    cd 7f bd

        call Lbd7f_add_map_ptr_offset

#bd7d

#55fd

2

13

    18 ed

        jr Lbd6c_loop

#bd7f

#55ff

#bd7f

#55ff

#bd7f

#55ff

    ; --------------------------------

#bd7f

#55ff

    ; Adds an (x, y) offset to a map pointer.

#bd7f

#55ff

    ; Input:

#bd7f

#55ff

    ; - hl: map pointer

#bd7f

#55ff

    ; - c: offset in x

#bd7f

#55ff

    ; - b: offset in y

#bd7f

#55ff

    Lbd7f_add_map_ptr_offset:

#bd7f

#55ff

1

12

    d5

        push de

#bd80

#5600

            ; hl += c

#bd80

#5600

            ; extend c to 16 bits in de:

#bd80

#5600

1

5

    59

            ld e, c

#bd81

#5601

2

8

    16 00

            ld d, 0

#bd83

#5603

1

5

    79

            ld a, c

#bd84

#5604

1

5

    b7

            or a

#bd85

#5605

3

11

    f2 8a bd

            jp p, Lbd8a_c_positive

#bd88

#5608

2

8

    16 ff

            ld d, 255

#bd8a

#560a

    Lbd8a_c_positive:

#bd8a

#560a

1

12

    19

            add hl, de

#bd8b

#560b

1

5

    7c

            ld a, h

#bd8c

#560c

1

5

    80

            add a, b

#bd8d

#560d

1

5

    80

            add a, b

#bd8e

#560e

1

5

    67

            ld h, a  ; h += b*2

#bd8f

#560f

1

11

    d1

        pop de

#bd90

#5610

1

11

    c9

        ret

#bd91

#5611

#bd91

#5611

#bd91

#5611

    ; --------------------------------

#bd91

#5611

    ; Adds an element (building, terrain) to the map.

#bd91

#5611

    ; This methods adds the desired element to a 2x2 grid, and marks the bottom-left with bit 5 to 0,

#bd91

#5611

    ; and the rest with bit 5 to 1.

#bd91

#5611

    ; Input:

#bd91

#5611

    ; - hl: map ptr

#bd91

#5611

    ; - a: map element.

#bd91

#5611

    Lbd91_add_element_to_map:

#bd91

#5611

1

12

    d5

        push de

#bd92

#5612

1

5

    5f

            ld e, a

#bd93

#5613

3

11

    01 02 02

            ld bc, #0202

#bd96

#5616

1

12

    e5

            push hl

#bd97

#5617

    Lbd97_loop_y:

#bd97

#5617

1

12

    c5

                push bc

#bd98

#5618

1

12

    e5

                push hl

#bd99

#5619

    Lbd99_loop_x:

#bd99

#5619

1

8

    73

                    ld (hl), e  ; write the type of map element we have in this position.

#bd9a

#561a

2

10

    cb eb

                    set 5, e  ; only the bottom-left corner has bit 5 set to 0, the rest have it to 1.

#bd9c

#561c

1

7

    23

                    inc hl

#bd9d

#561d

2

14/9

    10 fa

                    djnz Lbd99_loop_x

#bd9f

#561f

1

11

    e1

                pop hl

#bda0

#5620

1

11

    c1

                pop bc

#bda1

#5621

1

5

    25

                dec h  ; y -= 1

#bda2

#5622

1

5

    25

                dec h

#bda3

#5623

1

5

    0d

                dec c

#bda4

#5624

2

13/8

    20 f1

                jr nz, Lbd97_loop_y

#bda6

#5626

1

11

    e1

            pop hl

#bda7

#5627

1

11

    d1

        pop de

#bda8

#5628

1

11

    c9

        ret

#bda9

#5629

#bda9

#5629

#bda9

#5629

        ; --------------------------------

#bda9

#5629

        ; Game map data:

#bda9

#5629

        ; Each block of 3 bytes represents a map element: type, x, y.

#bda9

#5629

        ; - Element types with the most significant bit set to 1 represent complex structures, which

#bda9

#5629

        ;   are specified

#bda9

#5629

        ;   in "Lbf9c_map_complex_structure_ptrs".

#bda9

#5629

        ; - A 0 indicates termination.

#bda9

#5629

    Lbda9_map_elements_part1:  ; elements with x < 256

#bda9

#5629

3

        db #86, #0c, #01

#bdac

#562c

3

        db #86, #0c, #09

#bdaf

#562f

3

        db #11, #10, #0e

#bdb2

#5632

3

        db #11, #20, #03

#bdb5

#5635

3

        db #82, #22, #0a

#bdb8

#5638

3

        db #05, #20, #0c

#bdbb

#563b

3

        db #04, #2a, #0a

#bdbe

#563e

3

        db #07, #2a, #0c

#bdc1

#5641

3

        db #06, #2a, #0e

#bdc4

#5644

3

        db #03, #2c, #0a

#bdc7

#5647

3

        db #09, #2c, #0c

#bdca

#564a

3

        db #07, #2c, #0e

#bdcd

#564d

3

        db #83, #2e, #0a

#bdd0

#5650

3

        db #03, #30, #08

#bdd3

#5653

3

        db #04, #32, #08

#bdd6

#5656

3

        db #02, #36, #0c

#bdd9

#5659

3

        db #06, #36, #0e

#bddc

#565c

3

        db #03, #38, #0e

#bddf

#565f

3

        db #12, #3f, #02

#bde2

#5662

3

        db #12, #41, #02

#bde5

#5665

3

        db #12, #46, #01

#bde8

#5668

3

        db #11, #46, #0f

#bdeb

#566b

3

        db #11, #48, #0f

#bdee

#566e

3

        db #87, #48, #02

#bdf1

#5671

3

        db #87, #53, #08

#bdf4

#5674

3

        db #06, #53, #02

#bdf7

#5677

3

        db #05, #53, #04

#bdfa

#567a

3

        db #83, #55, #02

#bdfd

#567d

3

        db #02, #55, #06

#be00

#5680

3

        db #04, #5b, #06

#be03

#5683

3

        db #07, #5d, #02

#be06

#5686

3

        db #03, #5d, #04

#be09

#5689

3

        db #85, #5e, #0f

#be0c

#568c

3

        db #88, #68, #09

#be0f

#568f

3

        db #88, #6e, #09

#be12

#5692

3

        db #0d, #6e, #09

#be15

#5695

3

        db #85, #6a, #04

#be18

#5698

3

        db #85, #6c, #0d

#be1b

#569b

3

        db #84, #79, #09

#be1e

#569e

3

        db #11, #7f, #0c

#be21

#56a1

3

        db #11, #81, #07

#be24

#56a4

3

        db #85, #86, #04

#be27

#56a7

3

        db #12, #85, #0b

#be2a

#56aa

3

        db #12, #85, #0d

#be2d

#56ad

3

        db #87, #97, #06

#be30

#56b0

3

        db #82, #a5, #02

#be33

#56b3

3

        db #83, #a7, #06

#be36

#56b6

3

        db #83, #ad, #08

#be39

#56b9

3

        db #83, #b3, #0a

#be3c

#56bc

3

        db #12, #bf, #08

#be3f

#56bf

3

        db #89, #bf, #03

#be42

#56c2

3

        db #89, #c1, #08

#be45

#56c5

3

        db #89, #bf, #0d

#be48

#56c8

3

        db #89, #c7, #03

#be4b

#56cb

3

        db #89, #c7, #0d

#be4e

#56ce

3

        db #89, #cf, #03

#be51

#56d1

3

        db #89, #c9, #08

#be54

#56d4

3

        db #89, #cf, #0d

#be57

#56d7

3

        db #12, #d1, #08

#be5a

#56da

3

        db #89, #d7, #0d

#be5d

#56dd

3

        db #89, #df, #0d

#be60

#56e0

3

        db #11, #e5, #0b

#be63

#56e3

3

        db #84, #e9, #09

#be66

#56e6

3

        db #12, #e9, #07

#be69

#56e9

3

        db #82, #eb, #0a

#be6c

#56ec

3

        db #82, #f3, #0a

#be6f

#56ef

3

        db #02, #fb, #0c

#be72

#56f2

3

        db #04, #fb, #0e

#be75

#56f5

3

        db #03, #fd, #0e

#be78

#56f8

1

        db #00

#be79

#56f9

#be79

#56f9

    Lbe79_map_elements_part2:  ; elements with x >= 256

#be79

#56f9

3

        db #83, #0e, #02

#be7c

#56fc

3

        db #83, #0c, #0a

#be7f

#56ff

3

        db #83, #10, #0a

#be82

#5702

3

        db #08, #08, #0e

#be85

#5705

3

        db #09, #0a, #0c

#be88

#5708

3

        db #0a, #0a, #0e

#be8b

#570b

3

        db #08, #18, #0c

#be8e

#570e

3

        db #0b, #18, #0e

#be91

#5711

3

        db #12, #21, #03

#be94

#5714

3

        db #11, #2b, #09

#be97

#5717

3

        db #12, #33, #0d

#be9a

#571a

3

        db #11, #40, #0a

#be9d

#571d

3

        db #11, #42, #0c

#bea0

#5720

3

        db #11, #44, #0e

#bea3

#5723

3

        db #12, #49, #0c

#bea6

#5726

3

        db #85, #50, #05

#bea9

#5729

3

        db #85, #50, #09

#beac

#572c

3

        db #85, #58, #05

#beaf

#572f

3

        db #85, #58, #09

#beb2

#5732

3

        db #84, #60, #09

#beb5

#5735

3

        db #12, #5e, #01

#beb8

#5738

3

        db #12, #5e, #03

#bebb

#573b

3

        db #11, #58, #01

#bebe

#573e

3

        db #11, #52, #03

#bec1

#5741

3

        db #11, #52, #0d

#bec4

#5744

3

        db #11, #56, #0d

#bec7

#5747

3

        db #11, #56, #0f

#beca

#574a

3

        db #11, #58, #0f

#becd

#574d

3

        db #11, #5a, #0f

#bed0

#5750

3

        db #11, #5a, #0b

#bed3

#5753

3

        db #8a, #64, #05

#bed6

#5756

3

        db #11, #7b, #04

#bed9

#5759

3

        db #03, #7b, #0e

#bedc

#575c

3

        db #04, #7d, #0c

#bedf

#575f

3

        db #02, #7d, #0e

#bee2

#5762

3

        db #82, #7f, #0a

#bee5

#5765

3

        db #05, #87, #0c

#bee8

#5768

3

        db #02, #87, #0e

#beeb

#576b

3

        db #04, #89, #0e

#beee

#576e

3

        db #12, #8a, #01

#bef1

#5771

3

        db #11, #91, #0f

#bef4

#5774

3

        db #12, #99, #01

#bef7

#5777

3

        db #88, #96, #05

#befa

#577a

3

        db #88, #99, #09

#befd

#577d

3

        db #88, #99, #0d

#bf00

#5780

3

        db #87, #a4, #08

#bf03

#5783

3

        db #87, #a8, #02

#bf06

#5786

3

        db #87, #ac, #08

#bf09

#5789

3

        db #87, #b0, #02

#bf0c

#578c

3

        db #09, #b4, #0e

#bf0f

#578f

3

        db #83, #b6, #0a

#bf12

#5792

3

        db #83, #bc, #0a

#bf15

#5795

3

        db #04, #c0, #0a

#bf18

#5798

3

        db #03, #c2, #0a

#bf1b

#579b

3

        db #02, #c2, #0c

#bf1e

#579e

3

        db #88, #c5, #03

#bf21

#57a1

3

        db #11, #d0, #0a

#bf24

#57a4

3

        db #11, #d3, #0d

#bf27

#57a7

3

        db #8a, #de, #01

#bf2a

#57aa

3

        db #8a, #dc, #03

#bf2d

#57ad

3

        db #8a, #da, #05

#bf30

#57b0

3

        db #8a, #da, #09

#bf33

#57b3

3

        db #8a, #dc, #0b

#bf36

#57b6

3

        db #8a, #de, #0d

#bf39

#57b9

3

        db #8a, #e0, #0f

#bf3c

#57bc

3

        db #8a, #e0, #05

#bf3f

#57bf

3

        db #86, #f7, #01

#bf42

#57c2

3

        db #86, #f7, #09

#bf45

#57c5

1

        db #00

#bf46

#57c6

#bf46

#57c6

        ; Warbases and factories:

#bf46

#57c6

        ; 0 are warbases, and 1 - 6 are factories

#bf46

#57c6

    Lbf46_warbases_factories_part1:

#bf46

#57c6

3

        db #00, #16, #09

#bf49

#57c9

3

        db #04, #27, #06

#bf4c

#57cc

3

        db #06, #35, #03

#bf4f

#57cf

3

        db #01, #3e, #0a

#bf52

#57d2

3

        db #05, #4f, #03

#bf55

#57d5

3

        db #03, #61, #03

#bf58

#57d8

3

        db #02, #7d, #03

#bf5b

#57db

3

        db #06, #8c, #0b

#bf5e

#57de

3

        db #01, #a0, #05

#bf61

#57e1

3

        db #03, #b4, #03

#bf64

#57e4

3

        db #04, #d9, #03

#bf67

#57e7

3

        db #05, #e3, #09

#bf6a

#57ea

3

        db #06, #f1, #03

#bf6d

#57ed

1

        db #ff

#bf6e

#57ee

#bf6e

#57ee

    Lbf6e_warbases_factories_part2:

#bf6e

#57ee

3

        db #00, #05, #08

#bf71

#57f1

3

        db #03, #1a, #03

#bf74

#57f4

3

        db #01, #20, #0d

#bf77

#57f7

3

        db #02, #28, #03

#bf7a

#57fa

3

        db #04, #37, #07

#bf7d

#57fd

3

        db #06, #42, #03

#bf80

#5800

3

        db #00, #71, #08

#bf83

#5803

3

        db #03, #82, #03

#bf86

#5806

3

        db #05, #91, #07

#bf89

#5809

3

        db #01, #a0, #03

#bf8c

#580c

3

        db #02, #b4, #05

#bf8f

#580f

3

        db #04, #be, #03

#bf92

#5812

3

        db #05, #c8, #0a

#bf95

#5815

3

        db #06, #d2, #03

#bf98

#5818

3

        db #00, #ee, #08

#bf9b

#581b

1

        db #ff

#bf9c

#581c

#bf9c

#581c

    Lbf9c_map_complex_structure_ptrs:

#bf9c

#581c

2

        dw Lbfb2_warbase

#bf9e

#581e

2

        dw Lbfe2_factory

#bfa0

#5820

2

        dw Lbff4

#bfa2

#5822

2

        dw Lc018

#bfa4

#5824

2

        dw Lc03c

#bfa6

#5826

2

        dw Lc048

#bfa8

#5828

2

        dw Lc054

#bfaa

#582a

2

        dw Lc060

#bfac

#582c

2

        dw Lc06c

#bfae

#582e

2

        dw Lc078

#bfb0

#5830

2

        dw Lc084

#bfb2

#5832

#bfb2

#5832

        ; Each complex structure is a list of map elements. Termination is marked by an

#bfb2

#5832

        ; element with x == y == 0.

#bfb2

#5832

    Lbfb2_warbase:

#bfb2

#5832

3

        db #00, #fc, #fc

#bfb5

#5835

3

        db #10, #00, #fe

#bfb8

#5838

3

        db #10, #02, #05

#bfbb

#583b

3

        db #0f, #00, #fe

#bfbe

#583e

3

        db #0f, #00, #fe

#bfc1

#5841

3

        db #0f, #00, #fe

#bfc4

#5844

3

        db #10, #02, #05

#bfc7

#5847

3

        db #0f, #00, #fe

#bfca

#584a

3

        db #10, #00, #fe

#bfcd

#584d

3

        db #10, #02, #05

#bfd0

#5850

3

        db #0f, #00, #fe

#bfd3

#5853

3

        db #0f, #00, #fe

#bfd6

#5856

3

        db #0f, #00, #fe

#bfd9

#5859

3

        db #10, #02, #03

#bfdc

#585c

3

        db #10, #00, #fe

#bfdf

#585f

3

        db #10, #00, #00

#bfe2

#5862

#bfe2

#5862

    Lbfe2_factory:

#bfe2

#5862

3

        db #00, #fe, #00

#bfe5

#5865

3

        db #0f, #00, #fe

#bfe8

#5868

3

        db #10, #02, #00

#bfeb

#586b

3

        db #10, #02, #00

#bfee

#586e

3

        db #10, #00, #02

#bff1

#5871

3

        db #0f, #00, #00

#bff4

#5874

#bff4

#5874

    Lbff4:

#bff4

#5874

3

        db #02, #02, #00

#bff7

#5877

3

        db #03, #02, #00

#bffa

#587a

3

        db #04, #02, #00

#bffd

#587d

3

        db #05, #fa, #02

#c000

#5880

3

        db #04, #02, #00

#c003

#5883

3

        db #05, #02, #00

#c006

#5886

3

        db #02, #02, #00

#c009

#5889

3

        db #03, #fa, #02

#c00c

#588c

3

        db #03, #02, #00

#c00f

#588f

3

        db #02, #02, #00

#c012

#5892

3

        db #05, #02, #00

#c015

#5895

3

        db #04, #00, #00

#c018

#5898

#c018

#5898

    Lc018:

#c018

#5898

3

        db #08, #02, #00

#c01b

#589b

3

        db #09, #02, #00

#c01e

#589e

3

        db #0a, #02, #00

#c021

#58a1

3

        db #0b, #fa, #02

#c024

#58a4

3

        db #0a, #02, #00

#c027

#58a7

3

        db #0b, #02, #00

#c02a

#58aa

3

        db #08, #02, #00

#c02d

#58ad

3

        db #09, #fa, #02

#c030

#58b0

3

        db #09, #02, #00

#c033

#58b3

3

        db #08, #02, #00

#c036

#58b6

3

        db #0b, #02, #00

#c039

#58b9

3

        db #0a, #00, #00

#c03c

#58bc

#c03c

#58bc

    Lc03c:

#c03c

#58bc

3

        db #12, #00, #02

#c03f

#58bf

3

        db #12, #00, #02

#c042

#58c2

3

        db #12, #00, #02

#c045

#58c5

3

        db #12, #00, #00

#c048

#58c8

#c048

#58c8

    Lc048:

#c048

#58c8

3

        db #12, #02, #00

#c04b

#58cb

3

        db #12, #02, #00

#c04e

#58ce

3

        db #12, #02, #00

#c051

#58d1

3

        db #12, #00, #00

#c054

#58d4

#c054

#58d4

    Lc054:

#c054

#58d4

3

        db #15, #00, #02

#c057

#58d7

3

        db #15, #00, #02

#c05a

#58da

3

        db #15, #00, #02

#c05d

#58dd

3

        db #15, #00, #00

#c060

#58e0

#c060

#58e0

    Lc060:

#c060

#58e0

3

        db #0c, #00, #02

#c063

#58e3

3

        db #0d, #00, #02

#c066

#58e6

3

        db #0d, #00, #02

#c069

#58e9

3

        db #0e, #00, #00

#c06c

#58ec

#c06c

#58ec

    Lc06c:

#c06c

#58ec

3

        db #0c, #02, #00

#c06f

#58ef

3

        db #0d, #02, #00

#c072

#58f2

3

        db #0d, #02, #00

#c075

#58f5

3

        db #0e, #00, #00

#c078

#58f8

#c078

#58f8

    Lc078:

#c078

#58f8

3

        db #11, #02, #00

#c07b

#58fb

3

        db #11, #02, #00

#c07e

#58fe

3

        db #11, #02, #00

#c081

#5901

3

        db #11, #00, #00

#c084

#5904

#c084

#5904

    Lc084:

#c084

#5904

3

        db #11, #02, #00

#c087

#5907

3

        db #12, #02, #00

#c08a

#590a

3

        db #11, #00, #00

#c08d

#590d

#c08d

#590d

#c08d

#590d

115

        ds #c100 - $, 0  ; 115 bytes of empty space until the game code continues.

#c100

#5980

#c100

#5980

#c100

#5980

    ; --------------------------------

#c100

#5980

    Lc100_title_screen:

#c100

#5980

3

18

    cd b9 d0

        call Ld0b9_clear_screen

#c103

#5983

3

18

    cd e3 c1

        call Lc1e3_draw_game_title

#c106

#5986

    Lc106_title_screen_redraw_options:

#c106

#5986

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c109

#5989

        ; Script start:

#c109

#5989

2

            db CMD_SET_ATTRIBUTE, #46

#c10b

#598b

2

            db CMD_SET_SCALE, #21

#c10d

#598d

3

            db CMD_SET_POSITION, #0b, #08

#c110

#5990

13

            db "0..START GAME"

#c11d

#599d

2

            db CMD_SET_SCALE, #00

#c11f

#599f

1

            db CMD_END

#c120

#59a0

        ; Script end:

#c120

#59a0

2

8

    0e 01

        ld c, 1

#c122

#59a2

3

18

    cd 36 c3

        call Lc336_highlight_if_selected

#c125

#59a5

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c128

#59a8

        ; Script start:

#c128

#59a8

1

            db CMD_NEXT_LINE

#c129

#59a9

1

            db CMD_NEXT_LINE

#c12a

#59aa

1

            db CMD_NEXT_LINE

#c12b

#59ab

11

            db "1..KEYBOARD"

#c136

#59b6

1

            db CMD_END

#c137

#59b7

        ; Script end:

#c137

#59b7

2

8

    0e 02

        ld c, 2

#c139

#59b9

3

18

    cd 36 c3

        call Lc336_highlight_if_selected

#c13c

#59bc

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c13f

#59bf

        ; Script start:

#c13f

#59bf

1

            db CMD_NEXT_LINE

#c140

#59c0

1

            db CMD_NEXT_LINE

#c141

#59c1

15

            db "2..KEMPSTON J/S"

#c150

#59d0

1

            db CMD_END

#c151

#59d1

        ; Script end:

#c151

#59d1

2

8

    0e 03

        ld c, 3

#c153

#59d3

3

18

    cd 36 c3

        call Lc336_highlight_if_selected

#c156

#59d6

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c159

#59d9

        ; Script start:

#c159

#59d9

1

            db CMD_NEXT_LINE

#c15a

#59da

1

            db CMD_NEXT_LINE

#c15b

#59db

14

            db "3..INTERFACE 2"

#c169

#59e9

1

            db CMD_NEXT_LINE

#c16a

#59ea

1

            db CMD_NEXT_LINE

#c16b

#59eb

2

            db CMD_SET_ATTRIBUTE, #46

#c16d

#59ed

16

            db "4..REDEFINE KEYS"

#c17d

#59fd

1

            db CMD_NEXT_LINE

#c17e

#59fe

1

            db CMD_NEXT_LINE

#c17f

#59ff

18

            db "5..LOAD SAVED GAME"

#c191

#5a11

1

            db CMD_END

#c192

#5a12

        ; Script end:

#c192

#5a12

    Lc192_wait_for_key_not_pressed_loop:

#c192

#5a12

1

5

    76

        halt

#c193

#5a13

3

18

    cd 20 c8

        call Lc820_title_color_cycle

#c196

#5a16

3

18

    cd 8e 02

        call L028e_BIOS_POLL_KEYBOARD

#c199

#5a19

1

5

    7b

        ld a, e

#c19a

#5a1a

1

5

    b7

        or a

#c19b

#5a1b

3

11

    f2 92 c1

        jp p, Lc192_wait_for_key_not_pressed_loop

#c19e

#5a1e

3

18

    cd a7 c4

        call Lc4a7_title_music_loop

#c1a1

#5a21

    Lc1a1_wait_for_key_press_loop:

#c1a1

#5a21

1

5

    76

        halt

#c1a2

#5a22

3

18

    cd 20 c8

        call Lc820_title_color_cycle

#c1a5

#5a25

3

18

    cd 8e 02

        call L028e_BIOS_POLL_KEYBOARD

#c1a8

#5a28

1

5

    7b

        ld a, e

#c1a9

#5a29

1

5

    b7

        or a

#c1aa

#5a2a

3

11

    fa a1 c1

        jp m, Lc1a1_wait_for_key_press_loop

#c1ad

#5a2d

3

11

    21 05 02

        ld hl, L0205_BIOS_KEYCODE_TABLE

#c1b0

#5a30

1

5

    85

        add a, l

#c1b1

#5a31

1

5

    6f

        ld l, a

#c1b2

#5a32

1

8

    7e

        ld a, (hl)

#c1b3

#5a33

2

8

    fe 35

        cp "5"

#c1b5

#5a35

2

13/8

    28 46

        jr z, Lc1fd_select_load_saved_game

#c1b7

#5a37

2

8

    fe 30

        cp "0"

#c1b9

#5a39

2

13/8

    28 16

        jr z, Lc1d1_select_start_game

#c1bb

#5a3b

2

8

    fe 31

        cp "1"

#c1bd

#5a3d

2

13/8

    28 14

        jr z, Lc1d3_select_keyboard

#c1bf

#5a3f

2

8

    fe 32

        cp "2"

#c1c1

#5a41

2

13/8

    28 14

        jr z, Lc1d7_select_kempston

#c1c3

#5a43

2

8

    fe 33

        cp "3"

#c1c5

#5a45

2

13/8

    28 14

        jr z, Lc1db_select_interface2

#c1c7

#5a47

2

8

    fe 34

        cp "4"

#c1c9

#5a49

2

13/8

    20 d6

        jr nz, Lc1a1_wait_for_key_press_loop

#c1cb

#5a4b

3

18

    cd 4a c3

        call Lc34a_redefine_keys

#c1ce

#5a4e

3

11

    c3 00 c1

        jp Lc100_title_screen

#c1d1

#5a51

#c1d1

#5a51

    Lc1d1_select_start_game:

#c1d1

#5a51

1

5

    af

        xor a

#c1d2

#5a52

1

11

    c9

        ret

#c1d3

#5a53

#c1d3

#5a53

    Lc1d3_select_keyboard:

#c1d3

#5a53

2

8

    3e 01

        ld a, INPUT_KEYBOARD

#c1d5

#5a55

2

13

    18 06

        jr Lc1dd_select_input

#c1d7

#5a57

#c1d7

#5a57

    Lc1d7_select_kempston:

#c1d7

#5a57

2

8

    3e 02

        ld a, INPUT_KEMPSTON

#c1d9

#5a59

2

13

    18 02

        jr Lc1dd_select_input

#c1db

#5a5b

#c1db

#5a5b

    Lc1db_select_interface2:

#c1db

#5a5b

2

8

    3e 03

        ld a, INPUT_INTERFACE2

#c1dd

#5a5d

    Lc1dd_select_input:

#c1dd

#5a5d

3

14

    32 e4 d3

        ld (Ld3e4_input_type), a

#c1e0

#5a60

3

11

    c3 06 c1

        jp Lc106_title_screen_redraw_options

#c1e3

#5a63

#c1e3

#5a63

#c1e3

#5a63

    ; --------------------------------

#c1e3

#5a63

    Lc1e3_draw_game_title:

#c1e3

#5a63

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c1e6

#5a66

        ; Script start:

#c1e6

#5a66

3

            db CMD_SET_POSITION, #01, #0a

#c1e9

#5a69

2

            db CMD_SET_ATTRIBUTE, #47

#c1eb

#5a6b

2

            db CMD_SET_SCALE, #32

#c1ed

#5a6d

6

            db "NETHER"

#c1f3

#5a73

3

            db CMD_SET_POSITION, #05, #0b

#c1f6

#5a76

5

            db "EARTH"

#c1fb

#5a7b

1

            db CMD_END

#c1fc

#5a7c

        ; Script end:

#c1fc

#5a7c

1

11

    c9

        ret

#c1fd

#5a7d

#c1fd

#5a7d

#c1fd

#5a7d

    ; --------------------------------

#c1fd

#5a7d

    Lc1fd_select_load_saved_game:

#c1fd

#5a7d

3

18

    cd e3 c1

        call Lc1e3_draw_game_title

#c200

#5a80

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c203

#5a83

        ; Script start:

#c203

#5a83

3

            db CMD_SET_POSITION, #16, #07

#c206

#5a86

2

            db CMD_SET_ATTRIBUTE, #45

#c208

#5a88

2

            db CMD_SET_SCALE, #21

#c20a

#5a8a

19

            db "PRESS PLAY ON TAPE "

#c21d

#5a9d

1

            db CMD_END

#c21e

#5a9e

        ; Script end:

#c21e

#5a9e

2

8

    3e 02

        ld a, 2

#c220

#5aa0

2

12

    d3 fe

        out (ULA_PORT), a  ; change border color

#c222

#5aa2

4

16

    dd 21 00 5b

        ld ix, L5b00  ; Address to store the data read from tape

#c226

#5aa6

3

11

    11 02 00

        ld de, 2  ; read 2 bytes (checksum)

#c229

#5aa9

1

5

    af

        xor a

#c22a

#5aaa

1

5

    37

        scf

#c22b

#5aab

1

5

    14

        inc d

#c22c

#5aac

1

5

    08

        ex af, af'

#c22d

#5aad

1

5

    15

        dec d

#c22e

#5aae

1

5

    f3

        di

#c22f

#5aaf

3

18

    cd 62 05

        call L0562_BIOS_READ_FROM_TAPE_SKIP_TESTS

#c232

#5ab2

#c232

#5ab2

4

16

    dd 21 2b d9

        ld ix, Ld92b_save_game_start  ; Address to store the data read from tape

#c236

#5ab6

3

11

    11 d1 24

        ld de, Lfdfc_save_game_end - Ld92b_save_game_start  ; read 9425 bytes (the whole RAM space, up

#c239

#5ab9

                                                            ; to the interrupt table!)

#c239

#5ab9

1

5

    af

        xor a

#c23a

#5aba

1

5

    37

        scf

#c23b

#5abb

1

5

    14

        inc d

#c23c

#5abc

1

5

    08

        ex af, af'

#c23d

#5abd

1

5

    15

        dec d

#c23e

#5abe

1

5

    f3

        di

#c23f

#5abf

3

18

    cd 62 05

        call L0562_BIOS_READ_FROM_TAPE_SKIP_TESTS

#c242

#5ac2

#c242

#5ac2

1

5

    af

        xor a

#c243

#5ac3

2

12

    d3 fe

        out (ULA_PORT), a  ; border to black

#c245

#5ac5

#c245

#5ac5

        ; Make sure checksum is correct:

#c245

#5ac5

3

18

    cd 0f c3

        call Lc30f_compute_checksum

#c248

#5ac8

3

17

    2a 00 5b

        ld hl, (L5b00)

#c24b

#5acb

1

5

    a7

        and a

#c24c

#5acc

2

17

    ed 52

        sbc hl, de

#c24e

#5ace

1

5

    7c

        ld a, h

#c24f

#5acf

1

5

    b5

        or l

#c250

#5ad0

2

13/8

    20 17

        jr nz, Lc269_checksum_does_not_match

#c252

#5ad2

3

11

    21 2b d9

        ld hl, Ld92b_save_game_start

#c255

#5ad5

3

11

    11 d3 d7

        ld de, Ld7d3_bullets

#c258

#5ad8

3

11

    01 2d 00

        ld bc, MAX_BULLETS * BULLET_STRUCT_SIZE

#c25b

#5adb

2

23/18

    ed b0

        ldir  ; Restore the bullet state from the reading buffer.

#c25d

#5add

3

11

    11 01 ff

        ld de, Lff01_building_decorations

#c260

#5ae0

3

11

    01 a8 00

        ld bc, 168

#c263

#5ae3

2

23/18

    ed b0

        ldir

#c265

#5ae5

1

5

    fb

        ei

#c266

#5ae6

2

8

    f6 01

        or 1

#c268

#5ae8

1

11

    c9

        ret

#c269

#5ae9

#c269

#5ae9

#c269

#5ae9

    Lc269_checksum_does_not_match:

#c269

#5ae9

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c26c

#5aec

        ; Script start:

#c26c

#5aec

3

            db CMD_SET_POSITION, #16, #02

#c26f

#5aef

2

            db CMD_SET_ATTRIBUTE, #47

#c271

#5af1

2

            db CMD_SET_SCALE, #22

#c273

#5af3

14

            db "LOADING ERROR!"

#c281

#5b01

1

            db CMD_END

#c282

#5b02

        ; Script end:

#c282

#5b02

2

8

    3e fa

        ld a, 250

#c284

#5b04

3

18

    cd ac cc

        call Lccac_beep

#c287

#5b07

3

18

    cd 25 c3

        call Lc325_wait_for_key

#c28a

#5b0a

3

11

    c3 00 a6

        jp La600_start

#c28d

#5b0d

#c28d

#5b0d

#c28d

#5b0d

    ; --------------------------------

#c28d

#5b0d

    ; Saves the current game state to tape

#c28d

#5b0d

    Lc28d_save_game:

#c28d

#5b0d

3

11

    21 9c d5

        ld hl, Ld59c_empty_interrupt

#c290

#5b10

3

17

    22 fe fd

        ld (Lfdfe_interrupt_pointer), hl

#c293

#5b13

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c296

#5b16

        ; Script start:

#c296

#5b16

3

            db CMD_SET_POSITION, #16, #00

#c299

#5b19

2

            db CMD_SET_ATTRIBUTE, #45

#c29b

#5b1b

22

            db "PRESS RECORD AND PLAY "

#c2b1

#5b31

1

            db CMD_NEXT_LINE

#c2b2

#5b32

22

            db "     THEN ANY KEY     "

#c2c8

#5b48

1

            db CMD_END

#c2c9

#5b49

        ; Script end:

#c2c9

#5b49

3

18

    cd 25 c3

        call Lc325_wait_for_key

#c2cc

#5b4c

2

8

    3e 01

        ld a, 1

#c2ce

#5b4e

3

14

    32 52 fd

        ld (Lfd52_update_radar_buffer_signal), a

#c2d1

#5b51

3

11

    21 d3 d7

        ld hl, Ld7d3_bullets

#c2d4

#5b54

3

11

    11 2b d9

        ld de, Ld92b_save_game_start

#c2d7

#5b57

3

11

    01 2d 00

        ld bc, MAX_BULLETS * BULLET_STRUCT_SIZE

#c2da

#5b5a

2

23/18

    ed b0

        ldir  ; save the bullet state to a buffer for saving the game. Potential optimization: put the

#c2dc

#5b5c

              ; bullets here to begin with.

#c2dc

#5b5c

3

11

    21 01 ff

        ld hl, Lff01_building_decorations

#c2df

#5b5f

3

11

    01 a8 00

        ld bc, 168

#c2e2

#5b62

2

23/18

    ed b0

        ldir

#c2e4

#5b64

1

5

    f3

        di

#c2e5

#5b65

3

18

    cd 0f c3

        call Lc30f_compute_checksum

#c2e8

#5b68

4

22

    ed 53 00 5b

        ld (L5b00), de

#c2ec

#5b6c

3

11

    21 00 09

        ld hl, 2304  ; Data timing for saving bytes to disc

#c2ef

#5b6f

4

16

    dd 21 00 5b

        ld ix, L5b00

#c2f3

#5b73

3

11

    11 02 00

        ld de, 2  ; save 2 bytes to tape (checksum)

#c2f6

#5b76

1

5

    af

        xor a

#c2f7

#5b77

1

5

    37

        scf

#c2f8

#5b78

3

18

    cd d0 04

        call L04d0_BIOS_CASSETTE_SAVE_SKIP_TESTS

#c2fb

#5b7b

3

11

    21 00 09

        ld hl, 2304  ; Data timing for saving bytes to disc

#c2fe

#5b7e

4

16

    dd 21 2b d9

        ld ix, Ld92b_save_game_start

#c302

#5b82

3

11

    11 d1 24

        ld de, Lfdfc_save_game_end - Ld92b_save_game_start  ; save 9425 bytes to tape

#c305

#5b85

1

5

    af

        xor a

#c306

#5b86

1

5

    37

        scf

#c307

#5b87

3

18

    cd d0 04

        call L04d0_BIOS_CASSETTE_SAVE_SKIP_TESTS

#c30a

#5b8a

1

5

    af

        xor a

#c30b

#5b8b

2

12

    d3 fe

        out (ULA_PORT), a  ; border black

#c30d

#5b8d

1

5

    fb

        ei

#c30e

#5b8e

1

11

    c9

        ret

#c30f

#5b8f

#c30f

#5b8f

#c30f

#5b8f

    ; --------------------------------

#c30f

#5b8f

    ; Computes the checksum of the whole block of data that is saved

#c30f

#5b8f

    ; in a save game (9425 bytes)

#c30f

#5b8f

    Lc30f_compute_checksum:

#c30f

#5b8f

3

11

    21 2b d9

        ld hl, Ld92b_save_game_start

#c312

#5b92

3

11

    01 d1 24

        ld bc, Lfdfc_save_game_end - Ld92b_save_game_start

#c315

#5b95

3

11

    11 00 00

        ld de, 0

#c318

#5b98

    Lc318:

#c318

#5b98

1

8

    7e

        ld a, (hl)

#c319

#5b99

1

7

    23

        inc hl

#c31a

#5b9a

1

5

    83

        add a, e

#c31b

#5b9b

1

5

    5f

        ld e, a

#c31c

#5b9c

2

13/8

    30 01

        jr nc, Lc31f

#c31e

#5b9e

1

5

    14

        inc d

#c31f

#5b9f

    Lc31f:

#c31f

#5b9f

1

7

    0b

        dec bc

#c320

#5ba0

1

5

    78

        ld a, b

#c321

#5ba1

1

5

    b1

        or c

#c322

#5ba2

2

13/8

    20 f4

        jr nz, Lc318

#c324

#5ba4

1

11

    c9

        ret

#c325

#5ba5

#c325

#5ba5

#c325

#5ba5

    ; --------------------------------

#c325

#5ba5

    ; Waits until the user presses any key

#c325

#5ba5

    Lc325_wait_for_key:

#c325

#5ba5

        ; Wait until no key is pressed:

#c325

#5ba5

    Lc325_wait_for_key_loop1:

#c325

#5ba5

1

5

    af

        xor a

#c326

#5ba6

2

12

    db fe

        in a, (ULA_PORT)  ; a = high byte, ULA_PORT = low byte

#c328

#5ba8

1

5

    2f

        cpl

#c329

#5ba9

2

8

    e6 1f

        and 31

#c32b

#5bab

2

13/8

    20 f8

        jr nz, Lc325_wait_for_key_loop1

#c32d

#5bad

        ; Wait until the user presses any key:

#c32d

#5bad

    Lc32d_wait_for_key_loop2:

#c32d

#5bad

1

5

    af

        xor a

#c32e

#5bae

2

12

    db fe

        in a, (ULA_PORT)  ; a = high byte, ULA_PORT = low byte

#c330

#5bb0

1

5

    2f

        cpl

#c331

#5bb1

2

8

    e6 1f

        and 31

#c333

#5bb3

2

13/8

    28 f8

        jr z, Lc32d_wait_for_key_loop2

#c335

#5bb5

1

11

    c9

        ret

#c336

#5bb6

#c336

#5bb6

#c336

#5bb6

    ; --------------------------------

#c336

#5bb6

    Lc336_highlight_if_selected:

#c336

#5bb6

3

14

    3a e4 d3

        ld a, (Ld3e4_input_type)

#c339

#5bb9

1

5

    b9

        cp c

#c33a

#5bba

2

13/8

    28 07

        jr z, Lc343_highlight

#c33c

#5bbc

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c33f

#5bbf

        ; Script start:

#c33f

#5bbf

2

            db CMD_SET_ATTRIBUTE, #46

#c341

#5bc1

1

            db CMD_END

#c342

#5bc2

        ; Script end:

#c342

#5bc2

1

11

    c9

        ret

#c343

#5bc3

    Lc343_highlight:

#c343

#5bc3

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c346

#5bc6

        ; Script start:

#c346

#5bc6

2

            db CMD_SET_ATTRIBUTE, #45

#c348

#5bc8

1

            db CMD_END

#c349

#5bc9

        ; Script end:

#c349

#5bc9

1

11

    c9

        ret

#c34a

#5bca

#c34a

#5bca

#c34a

#5bca

    ; --------------------------------

#c34a

#5bca

    Lc34a_redefine_keys:

#c34a

#5bca

3

18

    cd b9 d0

        call Ld0b9_clear_screen

#c34d

#5bcd

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c350

#5bd0

        ; Script start:

#c350

#5bd0

3

            db CMD_SET_POSITION, #02, #09

#c353

#5bd3

2

            db CMD_SET_ATTRIBUTE, #47

#c355

#5bd5

2

            db CMD_SET_SCALE, #21

#c357

#5bd7

13

            db "REDEFINE KEYS"

#c364

#5be4

3

            db CMD_SET_POSITION, #05, #03

#c367

#5be7

2

            db CMD_SET_SCALE, #00

#c369

#5be9

1

            db CMD_END

#c36a

#5bea

        ; Script end:

#c36a

#5bea

    Lc36a_wait_for_no_key_pressed_loop:

#c36a

#5bea

3

18

    cd 8e 02

        call L028e_BIOS_POLL_KEYBOARD

#c36d

#5bed

1

5

    7b

        ld a, e

#c36e

#5bee

1

5

    b7

        or a

#c36f

#5bef

3

11

    f2 6a c3

        jp p, Lc36a_wait_for_no_key_pressed_loop

#c372

#5bf2

        ; Clear all the key definitions:

#c372

#5bf2

3

11

    21 cc d3

        ld hl, Ld3cc_key_pause

#c375

#5bf5

3

11

    11 cd d3

        ld de, Ld3cc_key_pause + 1

#c378

#5bf8

3

11

    01 17 00

        ld bc, 23

#c37b

#5bfb

2

11

    36 00

        ld (hl), 0

#c37d

#5bfd

2

23/18

    ed b0

        ldir

#c37f

#5bff

3

18

    cd 0c c4

        call Lc40c_print_press_key_for

#c382

#5c02

        ; Script start:

#c382

#5c02

5

            db "   UP"

#c387

#5c07

1

            db CMD_END

#c388

#5c08

        ; Script end:

#c388

#5c08

3

11

    21 da d3

        ld hl, Ld3d8_key_up + 2

#c38b

#5c0b

3

18

    cd 27 c4

        call Lc427_redefine_one_key

#c38e

#5c0e

3

18

    cd 0c c4

        call Lc40c_print_press_key_for

#c391

#5c11

        ; Script start:

#c391

#5c11

5

            db " DOWN"

#c396

#5c16

1

            db CMD_END

#c397

#5c17

        ; Script end:

#c397

#5c17

3

11

    21 dd d3

        ld hl, Ld3db_key_down + 2

#c39a

#5c1a

3

18

    cd 27 c4

        call Lc427_redefine_one_key

#c39d

#5c1d

3

18

    cd 0c c4

        call Lc40c_print_press_key_for

#c3a0

#5c20

        ; Script start:

#c3a0

#5c20

5

            db " LEFT"

#c3a5

#5c25

1

            db CMD_END

#c3a6

#5c26

        ; Script end:

#c3a6

#5c26

3

11

    21 e0 d3

        ld hl, Ld3de_key_left + 2

#c3a9

#5c29

3

18

    cd 27 c4

        call Lc427_redefine_one_key

#c3ac

#5c2c

3

18

    cd 0c c4

        call Lc40c_print_press_key_for

#c3af

#5c2f

        ; Script start:

#c3af

#5c2f

5

            db "RIGHT"

#c3b4

#5c34

1

            db CMD_END

#c3b5

#5c35

        ; Script end:

#c3b5

#5c35

3

11

    21 e3 d3

        ld hl, Ld3e1_key_right + 2

#c3b8

#5c38

3

18

    cd 27 c4

        call Lc427_redefine_one_key

#c3bb

#5c3b

3

18

    cd 0c c4

        call Lc40c_print_press_key_for

#c3be

#5c3e

        ; Script start:

#c3be

#5c3e

5

            db " FIRE"

#c3c3

#5c43

1

            db CMD_END

#c3c4

#5c44

        ; Script end:

#c3c4

#5c44

3

11

    21 d7 d3

        ld hl, Ld3d5_key_fire + 2

#c3c7

#5c47

3

18

    cd 27 c4

        call Lc427_redefine_one_key

#c3ca

#5c4a

3

18

    cd 70 d4

        call Ld470_execute_command_3_next_line

#c3cd

#5c4d

3

18

    cd 0c c4

        call Lc40c_print_press_key_for

#c3d0

#5c50

        ; Script start:

#c3d0

#5c50

5

            db "PAUSE"

#c3d5

#5c55

1

            db CMD_END

#c3d6

#5c56

        ; Script end:

#c3d6

#5c56

3

11

    21 ce d3

        ld hl, Ld3cc_key_pause + 2

#c3d9

#5c59

3

18

    cd 27 c4

        call Lc427_redefine_one_key

#c3dc

#5c5c

3

18

    cd 0c c4

        call Lc40c_print_press_key_for

#c3df

#5c5f

        ; Script start:

#c3df

#5c5f

5

            db "ABORT"

#c3e4

#5c64

1

            db CMD_END

#c3e5

#5c65

        ; Script end:

#c3e5

#5c65

3

11

    21 d1 d3

        ld hl, Ld3cf_key_abort + 2

#c3e8

#5c68

3

18

    cd 27 c4

        call Lc427_redefine_one_key

#c3eb

#5c6b

3

18

    cd 0c c4

        call Lc40c_print_press_key_for

#c3ee

#5c6e

        ; Script start:

#c3ee

#5c6e

5

            db " SAVE"

#c3f3

#5c73

1

            db CMD_END

#c3f4

#5c74

        ; Script end:

#c3f4

#5c74

3

11

    21 d4 d3

        ld hl, Ld3d2_key_save + 2

#c3f7

#5c77

3

18

    cd 27 c4

        call Lc427_redefine_one_key

#c3fa

#5c7a

    Lc3fa:

#c3fa

#5c7a

3

18

    cd 8e 02

        call L028e_BIOS_POLL_KEYBOARD

#c3fd

#5c7d

1

5

    7b

        ld a, e

#c3fe

#5c7e

1

5

    b7

        or a

#c3ff

#5c7f

3

11

    f2 fa c3

        jp p, Lc3fa

#c402

#5c82

3

11

    01 00 00

        ld bc, 0

#c405

#5c85

    Lc405:

#c405

#5c85

1

7

    0b

        dec bc

#c406

#5c86

1

5

    00

        nop

#c407

#5c87

1

5

    79

        ld a, c

#c408

#5c88

1

5

    b0

        or b

#c409

#5c89

2

13/8

    20 fa

        jr nz, Lc405

#c40b

#5c8b

1

11

    c9

        ret

#c40c

#5c8c

#c40c

#5c8c

#c40c

#5c8c

    ; --------------------------------

#c40c

#5c8c

    Lc40c_print_press_key_for:

#c40c

#5c8c

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c40f

#5c8f

        ; Script start:

#c40f

#5c8f

1

            db CMD_NEXT_LINE

#c410

#5c90

1

            db CMD_NEXT_LINE

#c411

#5c91

2

            db CMD_SET_ATTRIBUTE, #46

#c413

#5c93

14

            db "PRESS KEY FOR "

#c421

#5ca1

2

            db CMD_SET_ATTRIBUTE, #45

#c423

#5ca3

1

            db CMD_END

#c424

#5ca4

        ; Script end:

#c424

#5ca4

3

11

    c3 2d d4

        jp Ld42d_execute_ui_script

#c427

#5ca7

#c427

#5ca7

#c427

#5ca7

    ; --------------------------------

#c427

#5ca7

    Lc427_redefine_one_key:

#c427

#5ca7

1

12

    e5

        push hl

#c428

#5ca8

3

18

    cd 2d d4

            call Ld42d_execute_ui_script

#c42b

#5cab

            ; Script start:

#c42b

#5cab

2

                db "  "

#c42d

#5cad

2

                db CMD_SET_ATTRIBUTE, #46

#c42f

#5caf

1

                db CMD_END

#c430

#5cb0

            ; Script emd:

#c430

#5cb0

    Lc430_wait_for_key_pressed_loop:

#c430

#5cb0

3

18

    cd 8e 02

            call L028e_BIOS_POLL_KEYBOARD

#c433

#5cb3

1

5

    7b

            ld a, e

#c434

#5cb4

1

5

    b7

            or a

#c435

#5cb5

3

11

    fa 30 c4

            jp m, Lc430_wait_for_key_pressed_loop

#c438

#5cb8

3

11

    21 05 02

            ld hl, L0205_BIOS_KEYCODE_TABLE

#c43b

#5cbb

1

5

    85

            add a, l

#c43c

#5cbc

1

5

    6f

            ld l, a

#c43d

#5cbd

1

8

    7e

            ld a, (hl)

#c43e

#5cbe

1

5

    57

            ld d, a

#c43f

#5cbf

3

11

    21 ce d3

            ld hl, Ld3cc_key_pause + 2

#c442

#5cc2

2

8

    06 08

            ld b, 8

#c444

#5cc4

    Lc444_duplicate_key_check_loop:

#c444

#5cc4

1

8

    be

            cp (hl)  ; If they key is already used, ignore

#c445

#5cc5

2

13/8

    28 e9

            jr z, Lc430_wait_for_key_pressed_loop

#c447

#5cc7

1

7

    23

            inc hl

#c448

#5cc8

1

7

    23

            inc hl

#c449

#5cc9

1

7

    23

            inc hl

#c44a

#5cca

2

14/9

    10 f8

            djnz Lc444_duplicate_key_check_loop

#c44c

#5ccc

1

11

    e1

        pop hl

#c44d

#5ccd

1

8

    77

        ld (hl), a  ; assign the key haracter

#c44e

#5cce

1

5

    7b

        ld a, e

#c44f

#5ccf

2

8

    e6 07

        and #07

#c451

#5cd1

1

5

    4f

        ld c, a

#c452

#5cd2

2

10

    cb 3b

        srl e

#c454

#5cd4

2

10

    cb 3b

        srl e

#c456

#5cd6

2

10

    cb 3b

        srl e

#c458

#5cd8

1

5

    43

        ld b, e

#c459

#5cd9

1

5

    04

        inc b

#c45a

#5cda

2

8

    3e 20

        ld a, 32

#c45c

#5cdc

    Lc45c:

#c45c

#5cdc

1

5

    0f

        rrca

#c45d

#5cdd

2

14/9

    10 fd

        djnz Lc45c

#c45f

#5cdf

1

7

    2b

        dec hl

#c460

#5ce0

1

8

    77

        ld (hl), a

#c461

#5ce1

1

5

    41

        ld b, c

#c462

#5ce2

1

5

    04

        inc b

#c463

#5ce3

1

5

    af

        xor a

#c464

#5ce4

1

5

    3d

        dec a

#c465

#5ce5

    Lc465:

#c465

#5ce5

1

5

    1f

        rra

#c466

#5ce6

2

14/9

    10 fd

        djnz Lc465

#c468

#5ce8

1

7

    2b

        dec hl

#c469

#5ce9

1

8

    77

        ld (hl), a

#c46a

#5cea

1

5

    7a

        ld a, d

#c46b

#5ceb

2

8

    fe 0e

        cp 14

#c46d

#5ced

2

13/8

    20 0b

        jr nz, Lc47a_not_sym_shift

#c46f

#5cef

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c472

#5cf2

        ; Script start:

#c472

#5cf2

6

            db "SYM SH"

#c478

#5cf8

1

            db CMD_END

#c479

#5cf9

        ; Script end:

#c479

#5cf9

1

11

    c9

        ret

#c47a

#5cfa

    Lc47a_not_sym_shift:

#c47a

#5cfa

2

8

    fe 0d

        cp 13

#c47c

#5cfc

2

13/8

    20 0a

        jr nz, Lc488_not_enter

#c47e

#5cfe

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c481

#5d01

        ; Script start:

#c481

#5d01

5

            db "ENTER"

#c486

#5d06

1

            db CMD_END

#c487

#5d07

        ; Script end:

#c487

#5d07

1

11

    c9

        ret

#c488

#5d08

    Lc488_not_enter:

#c488

#5d08

2

8

    fe e3

        cp 227

#c48a

#5d0a

2

13/8

    20 0c

        jr nz, Lc498_not_caps_shift

#c48c

#5d0c

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c48f

#5d0f

        ; Script start:

#c48f

#5d0f

7

            db "CAPS SH"

#c496

#5d16

1

            db CMD_END

#c497

#5d17

        ; Script end:

#c497

#5d17

1

11

    c9

        ret

#c498

#5d18

    Lc498_not_caps_shift:

#c498

#5d18

2

8

    fe 20

        cp 32

#c49a

#5d1a

3

11

    c2 27 d4

        jp nz, Ld427_draw_character_saving_registers

#c49d

#5d1d

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c4a0

#5d20

        ; Script start:

#c4a0

#5d20

5

            db "SPACE"

#c4a5

#5d25

1

            db CMD_END

#c4a6

#5d26

        ; Script end:

#c4a6

#5d26

    Lc4a6:

#c4a6

#5d26

    Lc4a6_music_empty_event:  ; event 0

#c4a6

#5d26

1

11

    c9

        ret

#c4a7

#5d27

#c4a7

#5d27

#c4a7

#5d27

    ; --------------------------------

#c4a7

#5d27

    ; Waits until the player presses any number in the keyboard.

#c4a7

#5d27

    ; While waiting, the title color is cycled, and music is played

#c4a7

#5d27

    Lc4a7_title_music_loop:

#c4a7

#5d27

1

5

    f3

        di

#c4a8

#5d28

4

22

    ed 73 08 fd

            ld (Lfd08_stack_ptr_buffer), sp  ; store the stack pointer

#c4ac

#5d2c

3

11

    21 fd c4

            ld hl, Lc4fd_title_music_loop_interrupt

#c4af

#5d2f

3

17

    22 fe fd

            ld (Lfdfe_interrupt_pointer), hl

#c4b2

#5d32

3

11

    21 78 c6

            ld hl, Lc678_music_event_table_channel1

#c4b5

#5d35

3

11

    11 02 c7

            ld de, Lc702_music_event_table_channel2

#c4b8

#5d38

3

11

    01 01 01

            ld bc, #0101  ; duration of the current event in the music channels (c = 1, b = 1 means

#c4bb

#5d3b

                          ; they will be reevaluated in the next frame, in

#c4bb

#5d3b

                          ; "Lc4fd_title_music_loop_interrupt")

#c4bb

#5d3b

1

5

    d9

            exx

#c4bc

#5d3c

3

11

    21 65 c6

            ld hl, Lc665_percussion_loops

#c4bf

#5d3f

1

5

    fb

        ei

#c4c0

#5d40

2

8

    0e 01

        ld c, 1

#c4c2

#5d42

1

5

    76

        halt

#c4c3

#5d43

    Lc4c3:

#c4c3

#5d43

1

12

    f5

        push af

#c4c4

#5d44

3

14

    3a 0c fd

            ld a, (Lfd0c_keyboard_state)  ; Question: what is the effect of this?

#c4c7

#5d47

3

14

    32 0c fd

            ld (Lfd0c_keyboard_state), a

#c4ca

#5d4a

1

11

    f1

        pop af

#c4cb

#5d4b

    Lc4cb:

#c4cb

#5d4b

1

5

    15

        dec d  ; note: undefined the first time we enter this function

#c4cc

#5d4c

3

11

    c2 e0 c4

        jp nz, Lc4e0

#c4cf

#5d4f

        ; Produce a wave for channel 2: the events of the channel modify these parameters to produce

#c4cf

#5d4f

        ; the right wave.

#c4cf

#5d4f

    Lc4d0_selfmodifying: equ $ + 1

#c4cf

#5d4f

2

8

    16 37

        ld d, 55  ; mdl:self-modifying

#c4d1

#5d51

    Lc4d2_selfmodifying: equ $ + 1

#c4d1

#5d51

2

8

    3e 18

        ld a, 24  ; mdl:self-modifying

#c4d3

#5d53

2

12

    d3 fe

        out (ULA_PORT), a  ; produce sound (wave front up)

#c4d5

#5d55

    Lc4d6_selfmodifying: equ $ + 1

#c4d5

#5d55

2

8

    3e 0d

        ld a, 13  ; mdl:self-modifying

#c4d7

#5d57

    Lc4d7:

#c4d7

#5d57

1

5

    3d

        dec a

#c4d8

#5d58

3

11

    c2 d7 c4

        jp nz, Lc4d7

#c4db

#5d5b

2

12

    d3 fe

        out (ULA_PORT), a  ; produce sound (wave front down as a == 0)

#c4dd

#5d5d

3

11

    c3 e8 c4

        jp Lc4e8

#c4e0

#5d60

    Lc4e0:

#c4e0

#5d60

1

12

    f5

        push af

#c4e1

#5d61

3

14

    3a 0c fd

            ld a, (Lfd0c_keyboard_state)  ; Question: what is the effect of this?

#c4e4

#5d64

3

14

    32 0c fd

            ld (Lfd0c_keyboard_state), a

#c4e7

#5d67

1

11

    f1

        pop af

#c4e8

#5d68

    Lc4e8:

#c4e8

#5d68

1

5

    1d

        dec e

#c4e9

#5d69

3

11

    c2 c3 c4

        jp nz, Lc4c3

#c4ec

#5d6c

        ; Produce a wave for channel 1: the events of the channel modify these parameters to produce

#c4ec

#5d6c

        ; the right wave.

#c4ec

#5d6c

    Lc4ed_selfmodifying: equ $ + 1

#c4ec

#5d6c

2

8

    1e 7c

        ld e, 124  ; mdl:self-modifying

#c4ee

#5d6e

    Lc4ef_selfmodifying: equ $ + 1

#c4ee

#5d6e

2

8

    3e 18

        ld a, 24  ; mdl:self-modifying

#c4f0

#5d70

2

12

    d3 fe

        out (ULA_PORT), a  ; produce sound (wave front up)

#c4f2

#5d72

    Lc4f3_selfmodifying: equ $ + 1

#c4f2

#5d72

2

8

    3e 1f

        ld a, 31  ; mdl:self-modifying

#c4f4

#5d74

    Lc4f4:

#c4f4

#5d74

1

5

    3d

        dec a

#c4f5

#5d75

3

11

    c2 f4 c4

        jp nz, Lc4f4

#c4f8

#5d78

2

12

    d3 fe

        out (ULA_PORT), a  ; produce sound (wave front down as a == 0)

#c4fa

#5d7a

3

11

    c3 cb c4

        jp Lc4cb

#c4fd

#5d7d

#c4fd

#5d7d

#c4fd

#5d7d

    ; --------------------------------

#c4fd

#5d7d

    Lc4fd_title_music_loop_interrupt:

#c4fd

#5d7d

1

12

    f5

        push af

#c4fe

#5d7e

1

5

    0d

            dec c

#c4ff

#5d7f

3

18/11

    cc db c5

            call z, Lc5db_music_percussion

#c502

#5d82

1

5

    d9

            exx

#c503

#5d83

1

5

    0d

                dec c

#c504

#5d84

3

18/11

    cc 28 c5

                call z, Lc528_music_next_event_channel1  ; if the duration of the previous event

#c507

#5d87

                                                         ; reached 0, new event!

#c507

#5d87

1

5

    05

                dec b

#c508

#5d88

3

18/11

    cc 3b c5

                call z, Lc53b_music_next_event_channel2  ; if the duration of the previous event

#c50b

#5d8b

                                                        ; reached 0, new event!

#c50b

#5d8b

3

18

    cd 20 c8

                call Lc820_title_color_cycle

#c50e

#5d8e

2

8

    3e e7

                ld a, 231  ; read 4th and 5th keyboard rows (all the numbers).

#c510

#5d90

2

12

    db fe

                in a, (ULA_PORT)  ; a = high byte, ULA_PORT = low byte.

#c512

#5d92

1

5

    2f

                cpl

#c513

#5d93

2

8

    e6 1f

                and 31

#c515

#5d95

2

13/8

    20 04

                jr nz, Lc51b  ; If any number was pressed, exit the title music loop.

#c517

#5d97

1

5

    d9

            exx

#c518

#5d98

1

11

    f1

        pop af

#c519

#5d99

1

5

    fb

        ei

#c51a

#5d9a

1

11

    c9

        ret

#c51b

#5d9b

    Lc51b:

#c51b

#5d9b

1

5

    f3

        di

#c51c

#5d9c

4

22

    ed 7b 08 fd

            ld sp, (Lfd08_stack_ptr_buffer)  ; restore the stack pointer that was stored when entering

#c520

#5da0

                                             ; "Lc4a7_title_music_loop".

#c520

#5da0

3

11

    21 9c d5

            ld hl, Ld59c_empty_interrupt

#c523

#5da3

3

17

    22 fe fd

            ld (Lfdfe_interrupt_pointer), hl

#c526

#5da6

1

5

    fb

        ei

#c527

#5da7

1

11

    c9

        ret  ; this effectively returns from "Lc4a7_title_music_loop".

#c528

#5da8

#c528

#5da8

#c528

#5da8

    ; --------------------------------

#c528

#5da8

    ; Reads the next event from the music event table 1 and executes it

#c528

#5da8

    ; input:

#c528

#5da8

    ; - hl: next event

#c528

#5da8

    Lc528_music_next_event_channel1:

#c528

#5da8

1

8

    7e

        ld a, (hl)

#c529

#5da9

2

8

    fe 09

        cp 9

#c52b

#5dab

2

13/8

    38 22

        jr c, Lc54f_music_event_jump_table_channel1

#c52d

#5dad

3

14

    32 ed c4

        ld (Lc4ed_selfmodifying), a

#c530

#5db0

1

5

    0f

        rrca

#c531

#5db1

1

5

    0f

        rrca

#c532

#5db2

2

8

    e6 3f

        and #3f

#c534

#5db4

3

14

    32 f3 c4

        ld (Lc4f3_selfmodifying), a

#c537

#5db7

1

7

    23

        inc hl

#c538

#5db8

1

8

    4e

        ld c, (hl)

#c539

#5db9

1

7

    23

        inc hl

#c53a

#5dba

1

11

    c9

        ret

#c53b

#5dbb

#c53b

#5dbb

#c53b

#5dbb

    ; --------------------------------

#c53b

#5dbb

    ; Reads the next event from the music event table 2 and executes it

#c53b

#5dbb

    ; input:

#c53b

#5dbb

    ; - de: next event

#c53b

#5dbb

    Lc53b_music_next_event_channel2:

#c53b

#5dbb

1

8

    1a

        ld a, (de)

#c53c

#5dbc

2

8

    fe 09

        cp 9

#c53e

#5dbe

2

13/8

    38 2e

        jr c, Lc56e_music_event_jump_table_channel2

#c540

#5dc0

3

14

    32 d0 c4

        ld (Lc4d0_selfmodifying), a

#c543

#5dc3

1

5

    0f

        rrca

#c544

#5dc4

1

5

    0f

        rrca

#c545

#5dc5

2

8

    e6 3f

        and #3f

#c547

#5dc7

3

14

    32 d6 c4

        ld (Lc4d6_selfmodifying), a

#c54a

#5dca

1

7

    13

        inc de

#c54b

#5dcb

1

8

    1a

        ld a, (de)

#c54c

#5dcc

1

5

    47

        ld b, a

#c54d

#5dcd

1

7

    13

        inc de

#c54e

#5dce

1

11

    c9

        ret

#c54f

#5dcf

#c54f

#5dcf

#c54f

#5dcf

    ; --------------------------------

#c54f

#5dcf

    Lc54f_music_event_jump_table_channel1:

#c54f

#5dcf

1

12

    e5

        push hl

#c550

#5dd0

3

18

    cd 5b c6

        call Lc65b_jump_table_jump

#c553

#5dd3

3

11

    c3 a6 c4

        jp Lc4a6_music_empty_event

#c556

#5dd6

3

11

    c3 a7 c5

        jp Lc5a7_music_channel1_jump

#c559

#5dd9

3

11

    c3 8d c5

        jp Lc58d_music_channel1_call

#c55c

#5ddc

3

11

    c3 cc c5

        jp Lc5cc_set_percussion_ptr

#c55f

#5ddf

3

11

    c3 35 c6

        jp Lc635_activate_channel1

#c562

#5de2

3

11

    c3 3f c6

        jp Lc63f_silence_channel1

#c565

#5de5

3

11

    c3 bb c5

        jp Lc5bb_music_channel1_ret

#c568

#5de8

3

11

    c3 cc c5

        jp Lc5cc_set_percussion_ptr

#c56b

#5deb

3

11

    c3 cc c5

        jp Lc5cc_set_percussion_ptr

#c56e

#5dee

#c56e

#5dee

#c56e

#5dee

    ; --------------------------------

#c56e

#5dee

    Lc56e_music_event_jump_table_channel2:

#c56e

#5dee

1

12

    e5

        push hl

#c56f

#5def

3

18

    cd 5b c6

        call Lc65b_jump_table_jump

#c572

#5df2

3

11

    c3 a6 c4

        jp Lc4a6_music_empty_event

#c575

#5df5

3

11

    c3 b0 c5

        jp Lc5b0_music_channel2_jump

#c578

#5df8

3

11

    c3 99 c5

        jp Lc599_music_channel2_call

#c57b

#5dfb

3

11

    c3 cc c5

        jp Lc5cc_set_percussion_ptr

#c57e

#5dfe

3

11

    c3 48 c6

        jp Lc648_activate_channel2

#c581

#5e01

3

11

    c3 52 c6

        jp Lc652_silence_channel2

#c584

#5e04

3

11

    c3 c3 c5

        jp Lc5c3_music_channel2_ret

#c587

#5e07

3

11

    c3 cc c5

        jp Lc5cc_set_percussion_ptr

#c58a

#5e0a

3

11

    c3 cc c5

        jp Lc5cc_set_percussion_ptr

#c58d

#5e0d

#c58d

#5e0d

#c58d

#5e0d

    ; --------------------------------

#c58d

#5e0d

    ; Event 2

#c58d

#5e0d

    Lc58d_music_channel1_call:

#c58d

#5e0d

1

11

    e1

        pop hl

#c58e

#5e0e

1

7

    23

        inc hl

#c58f

#5e0f

1

8

    7e

        ld a, (hl)

#c590

#5e10

1

7

    23

        inc hl

#c591

#5e11

3

17

    22 54 fd

        ld (Lfd54_music_channel1_ret_address), hl

#c594

#5e14

1

8

    66

        ld h, (hl)

#c595

#5e15

1

5

    6f

        ld l, a

#c596

#5e16

3

11

    c3 28 c5

        jp Lc528_music_next_event_channel1

#c599

#5e19

#c599

#5e19

#c599

#5e19

    ; --------------------------------

#c599

#5e19

    ; Event 2

#c599

#5e19

    Lc599_music_channel2_call:

#c599

#5e19

1

11

    e1

        pop hl

#c59a

#5e1a

1

5

    eb

        ex de, hl

#c59b

#5e1b

1

7

    23

            inc hl

#c59c

#5e1c

1

8

    7e

            ld a, (hl)

#c59d

#5e1d

1

7

    23

            inc hl

#c59e

#5e1e

3

17

    22 56 fd

            ld (Lfd56_music_channel2_ret_address), hl

#c5a1

#5e21

1

8

    66

            ld h, (hl)

#c5a2

#5e22

1

5

    6f

            ld l, a

#c5a3

#5e23

1

5

    eb

        ex de, hl

#c5a4

#5e24

3

11

    c3 3b c5

        jp Lc53b_music_next_event_channel2

#c5a7

#5e27

#c5a7

#5e27

#c5a7

#5e27

    ; --------------------------------

#c5a7

#5e27

    ; Event 1

#c5a7

#5e27

    Lc5a7_music_channel1_jump:

#c5a7

#5e27

1

11

    e1

        pop hl

#c5a8

#5e28

1

7

    23

        inc hl

#c5a9

#5e29

1

8

    7e

        ld a, (hl)

#c5aa

#5e2a

1

7

    23

        inc hl

#c5ab

#5e2b

1

8

    66

        ld h, (hl)

#c5ac

#5e2c

1

5

    6f

        ld l, a

#c5ad

#5e2d

3

11

    c3 28 c5

        jp Lc528_music_next_event_channel1

#c5b0

#5e30

#c5b0

#5e30

#c5b0

#5e30

    ; --------------------------------

#c5b0

#5e30

    ; Event 1

#c5b0

#5e30

    Lc5b0_music_channel2_jump:

#c5b0

#5e30

1

11

    e1

        pop hl

#c5b1

#5e31

1

5

    eb

        ex de, hl

#c5b2

#5e32

1

7

    23

        inc hl

#c5b3

#5e33

1

8

    7e

        ld a, (hl)

#c5b4

#5e34

1

7

    23

        inc hl

#c5b5

#5e35

1

8

    66

        ld h, (hl)

#c5b6

#5e36

1

5

    6f

        ld l, a

#c5b7

#5e37

1

5

    eb

        ex de, hl

#c5b8

#5e38

3

11

    c3 3b c5

        jp Lc53b_music_next_event_channel2

#c5bb

#5e3b

#c5bb

#5e3b

#c5bb

#5e3b

    ; --------------------------------

#c5bb

#5e3b

    ; Event 6

#c5bb

#5e3b

    Lc5bb_music_channel1_ret:

#c5bb

#5e3b

1

11

    e1

        pop hl

#c5bc

#5e3c

3

17

    2a 54 fd

        ld hl, (Lfd54_music_channel1_ret_address)

#c5bf

#5e3f

1

7

    23

        inc hl

#c5c0

#5e40

3

11

    c3 28 c5

        jp Lc528_music_next_event_channel1

#c5c3

#5e43

#c5c3

#5e43

#c5c3

#5e43

    ; --------------------------------

#c5c3

#5e43

    ; Event 6

#c5c3

#5e43

    Lc5c3_music_channel2_ret:

#c5c3

#5e43

1

11

    e1

        pop hl

#c5c4

#5e44

4

22

    ed 5b 56 fd

        ld de, (Lfd56_music_channel2_ret_address)

#c5c8

#5e48

1

7

    13

        inc de

#c5c9

#5e49

3

11

    c3 3b c5

        jp Lc53b_music_next_event_channel2

#c5cc

#5e4c

#c5cc

#5e4c

#c5cc

#5e4c

    ; --------------------------------

#c5cc

#5e4c

    ; Event 3, 7 or 8

#c5cc

#5e4c

    Lc5cc_set_percussion_ptr:

#c5cc

#5e4c

1

11

    e1

        pop hl

#c5cd

#5e4d

1

7

    23

        inc hl

#c5ce

#5e4e

1

8

    7e

        ld a, (hl)

#c5cf

#5e4f

1

7

    23

        inc hl

#c5d0

#5e50

1

5

    d9

        exx

#c5d1

#5e51

1

5

    6f

            ld l, a

#c5d2

#5e52

1

5

    d9

        exx

#c5d3

#5e53

1

8

    7e

        ld a, (hl)

#c5d4

#5e54

1

7

    23

        inc hl

#c5d5

#5e55

1

5

    d9

        exx

#c5d6

#5e56

1

5

    67

            ld h, a

#c5d7

#5e57

1

5

    d9

        exx

#c5d8

#5e58

3

11

    c3 28 c5

        jp Lc528_music_next_event_channel1

#c5db

#5e5b

#c5db

#5e5b

#c5db

#5e5b

    ; --------------------------------

#c5db

#5e5b

    Lc5db_music_percussion:

#c5db

#5e5b

1

8

    7e

        ld a, (hl)

#c5dc

#5e5c

1

7

    23

        inc hl

#c5dd

#5e5d

2

8

    fe 01

        cp 1

#c5df

#5e5f

2

13/8

    28 20

        jr z, Lc601_go_to  ; command == 1: go-to

#c5e1

#5e61

1

5

    4f

        ld c, a  ; Otherwise, repeat the following command for "a" steps

#c5e2

#5e62

1

8

    7e

        ld a, (hl)

#c5e3

#5e63

1

7

    23

        inc hl

#c5e4

#5e64

2

8

    fe 02

        cp 2

#c5e6

#5e66

2

13/8

    28 2e

        jr z, Lc616_tone_drum  ; 2: beep

#c5e8

#5e68

1

5

    a7

        and a

#c5e9

#5e69

2

13/8

    28 1d

        jr z, Lc608_drum1  ; 0: noisy beep

#c5eb

#5e6b

        ; any number != 0 and != 2:

#c5eb

#5e6b

1

12

    e5

        push hl

#c5ec

#5e6c

2

8

    26 00

            ld h, 0  ; read 80 random bytes from the BIOS

#c5ee

#5e6e

2

8

    06 50

            ld b, 80

#c5f0

#5e70

    Lc5f0_drum2:

#c5f0

#5e70

1

8

    7e

            ld a, (hl)

#c5f1

#5e71

2

8

    e6 18

            and 24  ; sets all bits to 0 except those referring to MIC/EAR (to produce sound).

#c5f3

#5e73

2

12

    d3 fe

            out (ULA_PORT), a  ; change MIC/EAR state (to produce sound)

#c5f5

#5e75

1

5

    78

            ld a, b

#c5f6

#5e76

1

5

    2f

            cpl

#c5f7

#5e77

2

8

    e6 3f

            and 63

#c5f9

#5e79

    Lc5f9_wait_pulse_on:

#c5f9

#5e79

1

5

    3d

            dec a

#c5fa

#5e7a

2

13/8

    20 fd

            jr nz, Lc5f9_wait_pulse_on

#c5fc

#5e7c

1

7

    23

            inc hl

#c5fd

#5e7d

2

14/9

    10 f1

            djnz Lc5f0_drum2

#c5ff

#5e7f

1

11

    e1

        pop hl

#c600

#5e80

1

11

    c9

        ret

#c601

#5e81

#c601

#5e81

#c601

#5e81

    ; --------------------------------

#c601

#5e81

    Lc601_go_to:

#c601

#5e81

1

8

    7e

        ld a, (hl)

#c602

#5e82

1

7

    23

        inc hl

#c603

#5e83

1

8

    66

        ld h, (hl)

#c604

#5e84

1

5

    6f

        ld l, a

#c605

#5e85

3

11

    c3 db c5

        jp Lc5db_music_percussion

#c608

#5e88

#c608

#5e88

#c608

#5e88

    ; --------------------------------

#c608

#5e88

    Lc608_drum1:

#c608

#5e88

1

12

    e5

        push hl

#c609

#5e89

2

8

    26 08

            ld h, 8

#c60b

#5e8b

2

8

    06 60

            ld b, 96

#c60d

#5e8d

    Lc60d:

#c60d

#5e8d

1

8

    7e

            ld a, (hl)  ; This is just reading a random byte from the BIOS (so, probably to produce

#c60e

#5e8e

                        ; noise).

#c60e

#5e8e

2

8

    e6 18

            and 24

#c610

#5e90

2

12

    d3 fe

            out (ULA_PORT), a  ; change MIC/EAR state (to produce sound)

#c612

#5e92

2

14/9

    10 f9

            djnz Lc60d

#c614

#5e94

1

11

    e1

        pop hl

#c615

#5e95

1

11

    c9

        ret

#c616

#5e96

#c616

#5e96

#c616

#5e96

    ; --------------------------------

#c616

#5e96

    Lc616_tone_drum:

#c616

#5e96

1

8

    7e

        ld a, (hl)

#c617

#5e97

1

7

    23

        inc hl

#c618

#5e98

1

12

    e5

        push hl

#c619

#5e99

2

8

    06 30

            ld b, 48  ; number of pulses the sound wave will have

#c61b

#5e9b

1

5

    6f

            ld l, a

#c61c

#5e9c

1

5

    0f

            rrca

#c61d

#5e9d

1

5

    67

            ld h, a

#c61e

#5e9e

    Lc61e_wave_loop:

#c61e

#5e9e

1

5

    af

            xor a

#c61f

#5e9f

2

12

    d3 fe

            out (ULA_PORT), a  ; change MIC/EAR state (sound off)

#c621

#5ea1

1

5

    2d

            dec l

#c622

#5ea2

1

5

    7d

            ld a, l

#c623

#5ea3

    Lc623_wait_pulse_off:

#c623

#5ea3

1

5

    3d

            dec a

#c624

#5ea4

2

13/8

    20 fd

            jr nz, Lc623_wait_pulse_off

#c626

#5ea6

2

8

    3e 18

            ld a, 24

#c628

#5ea8

2

12

    d3 fe

            out (ULA_PORT), a  ; change MIC/EAR state (to produce sound)

#c62a

#5eaa

2

8

    3e 04

            ld a, 4

#c62c

#5eac

1

5

    84

            add a, h

#c62d

#5ead

1

5

    67

            ld h, a

#c62e

#5eae

    Lc62e_wait_pulse_on:

#c62e

#5eae

1

5

    3d

            dec a

#c62f

#5eaf

2

13/8

    20 fd

            jr nz, Lc62e_wait_pulse_on

#c631

#5eb1

2

14/9

    10 eb

            djnz Lc61e_wave_loop

#c633

#5eb3

1

11

    e1

        pop hl

#c634

#5eb4

1

11

    c9

        ret

#c635

#5eb5

#c635

#5eb5

#c635

#5eb5

    ; --------------------------------

#c635

#5eb5

    ; Event 4

#c635

#5eb5

    Lc635_activate_channel1:

#c635

#5eb5

1

11

    e1

        pop hl

#c636

#5eb6

2

8

    3e 18

        ld a, 24

#c638

#5eb8

3

14

    32 ef c4

        ld (Lc4ef_selfmodifying), a

#c63b

#5ebb

1

7

    23

        inc hl

#c63c

#5ebc

3

11

    c3 28 c5

        jp Lc528_music_next_event_channel1

#c63f

#5ebf

#c63f

#5ebf

#c63f

#5ebf

    ; --------------------------------

#c63f

#5ebf

    ; Event 5

#c63f

#5ebf

    Lc63f_silence_channel1:

#c63f

#5ebf

1

11

    e1

        pop hl

#c640

#5ec0

1

5

    af

        xor a

#c641

#5ec1

3

14

    32 ef c4

        ld (Lc4ef_selfmodifying), a

#c644

#5ec4

1

7

    23

        inc hl

#c645

#5ec5

3

11

    c3 28 c5

        jp Lc528_music_next_event_channel1

#c648

#5ec8

#c648

#5ec8

#c648

#5ec8

    ; --------------------------------

#c648

#5ec8

    ; Event 4

#c648

#5ec8

    Lc648_activate_channel2:

#c648

#5ec8

1

11

    e1

        pop hl

#c649

#5ec9

2

8

    3e 18

        ld a, 24

#c64b

#5ecb

3

14

    32 d2 c4

        ld (Lc4d2_selfmodifying), a

#c64e

#5ece

1

7

    13

        inc de

#c64f

#5ecf

3

11

    c3 3b c5

        jp Lc53b_music_next_event_channel2

#c652

#5ed2

#c652

#5ed2

#c652

#5ed2

    ; --------------------------------

#c652

#5ed2

    ; Event 5

#c652

#5ed2

    Lc652_silence_channel2:

#c652

#5ed2

1

11

    e1

        pop hl

#c653

#5ed3

1

5

    af

        xor a

#c654

#5ed4

3

14

    32 d2 c4

        ld (Lc4d2_selfmodifying), a

#c657

#5ed7

1

7

    13

        inc de

#c658

#5ed8

3

11

    c3 3b c5

        jp Lc53b_music_next_event_channel2

#c65b

#5edb

#c65b

#5edb

#c65b

#5edb

    ; --------------------------------

#c65b

#5edb

    ; Gets the pointer to the list of jumps from the stack, selects the pointer index "a", and jumps

#c65b

#5edb

    ; Input:

#c65b

#5edb

    ; - stack: jump table pointer

#c65b

#5edb

    ; - a: index of the function to jump to

#c65b

#5edb

    Lc65b_jump_table_jump:

#c65b

#5edb

1

5

    6f

        ld l, a

#c65c

#5edc

1

5

    87

        add a, a

#c65d

#5edd

1

5

    85

        add a, l  ; a = a*3

#c65e

#5ede

1

11

    e1

        pop hl  ; get the pointer to the jump table

#c65f

#5edf

        ; hl += a:

#c65f

#5edf

1

5

    85

        add a, l

#c660

#5ee0

1

5

    6f

        ld l, a

#c661

#5ee1

2

13/8

    30 01

        jr nc, Lc664

#c663

#5ee3

1

5

    24

        inc h

#c664

#5ee4

    Lc664:

#c664

#5ee4

1

5

    e9

        jp hl

#c665

#5ee5

#c665

#5ee5

#c665

#5ee5

    ; --------------------------------

#c665

#5ee5

    ; Title Music:

#c665

#5ee5

    ; Music in Nether Earth is defined in a scripting language with a series of commands, and has 3

#c665

#5ee5

    ; channels:

#c665

#5ee5

    ; - one channel just contains percussion loops

#c665

#5ee5

    ; - the other two channels (channel 1, channel 2) contain the notes.

#c665

#5ee5

    ; For example, command "2" is a "call" to a music subroutine, "3" is a "jump" to a different

#c665

#5ee5

    ; part of the score, etc. These commands basically index the functions in two jumptables:

#c665

#5ee5

    ; "Lc54f_music_event_jump_table_channel1" and "Lc54f_music_event_jump_table_channel2".

#c665

#5ee5

    Lc665_percussion_loops:

#c665

#5ee5

2

        db #20, #00  ; 32 steps of drum 1

#c667

#5ee7

3

        db #01, #65, #c6  ; go-to #c665

#c66a

#5eea

2

        db #20, #00  ; 32 steps of drum 1  [I think this is unused]

#c66c

#5eec

    Lc66c:

#c66c

#5eec

2

        db #10, #01  ; 16 steps of drum 2

#c66e

#5eee

2

        db #08, #00  ; 8 steps of drum 1

#c670

#5ef0

2

        db #08, #00  ; 8 steps of drum 1

#c672

#5ef2

3

        db #20, #02, #30  ; 32 steps of clean beep drum instrument

#c675

#5ef5

3

        db #01, #6c, #c6  ; go-to #c66c

#c678

#5ef8

#c678

#5ef8

    Lc678_music_event_table_channel1:

#c678

#5ef8

3

        db #03, #65, #c6

#c67b

#5efb

3

        db #02, #bd, #c6  ; call Lc6bd

#c67e

#5efe

3

        db #02, #bd, #c6  ; call Lc6bd

#c681

#5f01

3

        db #02, #bd, #c6  ; call Lc6bd

#c684

#5f04

3

        db #02, #bd, #c6  ; call Lc6bd

#c687

#5f07

3

        db #03, #6c, #c6

#c68a

#5f0a

3

        db #02, #cc, #c6  ; call Lc6cc

#c68d

#5f0d

3

        db #02, #cc, #c6  ; call Lc6cc

#c690

#5f10

3

        db #02, #dd, #c6  ; call Lc6dd

#c693

#5f13

3

        db #02, #dd, #c6  ; call Lc6dd

#c696

#5f16

3

        db #02, #dd, #c6  ; call Lc6dd

#c699

#5f19

3

        db #02, #dd, #c6  ; call Lc6dd

#c69c

#5f1c

3

        db #02, #dd, #c6  ; call Lc6dd

#c69f

#5f1f

3

        db #02, #dd, #c6  ; call Lc6dd

#c6a2

#5f22

3

        db #02, #dd, #c6  ; call Lc6dd

#c6a5

#5f25

3

        db #02, #dd, #c6  ; call Lc6dd

#c6a8

#5f28

3

        db #02, #cc, #c6  ; call Lc6cc

#c6ab

#5f2b

3

        db #02, #cc, #c6  ; call Lc6cc

#c6ae

#5f2e

3

        db #02, #cc, #c6  ; call Lc6cc

#c6b1

#5f31

3

        db #02, #cc, #c6  ; call Lc6cc

#c6b4

#5f34

3

        db #02, #cc, #c6  ; call Lc6cc

#c6b7

#5f37

3

        db #03, #65, #c6

#c6ba

#5f3a

3

        db #01, #78, #c6  ; jump back to the beginning

#c6bd

#5f3d

    Lc6bd:

#c6bd

#5f3d

14

        db #7c, #10, #05, #7c, #08, #04, #7c, #10, #05, #7c, #40, #52, #18, #04

#c6cb

#5f4b

1

        db #06  ; ret

#c6cc

#5f4c

    Lc6cc:

#c6cc

#5f4c

16

        db #7c, #40, #6e, #40, #68, #40, #5d, #40, #7c, #40, #6e, #40, #68, #40, #5d, #40

#c6dc

#5f5c

1

        db #06  ; ret

#c6dd

#5f5d

    Lc6dd:

#c6dd

#5f5d

16

        db #7c, #08, #05, #7c, #08, #04, #7c, #08, #05, #7c, #08, #04, #7c, #08, #8b, #08

#c6ed

#5f6d

16

        db #93, #08, #a5, #08, #ba, #08, #a5, #08, #93, #08, #8b, #08, #7c, #08, #8b, #08

#c6fd

#5f7d

4

        db #93, #08, #a5, #08

#c701

#5f81

1

        db #06  ; ret

#c702

#5f82

#c702

#5f82

    Lc702_music_event_table_channel2:

#c702

#5f82

3

        db #02, #89, #c7  ; call Lc789

#c705

#5f85

3

        db #02, #89, #c7  ; call Lc789

#c708

#5f88

3

        db #02, #89, #c7  ; call Lc789

#c70b

#5f8b

3

        db #02, #89, #c7  ; call Lc789

#c70e

#5f8e

3

        db #02, #aa, #c7  ; call Lc7aa

#c711

#5f91

3

        db #02, #aa, #c7  ; call Lc7aa

#c714

#5f94

3

        db #02, #aa, #c7  ; call Lc7aa

#c717

#5f97

3

        db #02, #aa, #c7  ; call Lc7aa

#c71a

#5f9a

1

        db #05

#c71b

#5f9b

3

        db #02, #aa, #c7  ; call Lc7aa

#c71e

#5f9e

1

        db #04

#c71f

#5f9f

3

        db #02, #c5, #c7  ; call Lc7c5

#c722

#5fa2

3

        db #02, #c5, #c7  ; call Lc7c5

#c725

#5fa5

3

        db #02, #c5, #c7  ; call Lc7c5

#c728

#5fa8

3

        db #02, #c5, #c7  ; call Lc7c5

#c72b

#5fab

3

        db #02, #c5, #c7  ; call Lc7c5

#c72e

#5fae

3

        db #02, #d2, #c7  ; call Lc7d2

#c731

#5fb1

3

        db #02, #c5, #c7  ; call Lc7c5

#c734

#5fb4

3

        db #02, #d2, #c7  ; call Lc7d2

#c737

#5fb7

3

        db #02, #c5, #c7  ; call Lc7c5

#c73a

#5fba

3

        db #02, #d2, #c7  ; call Lc7d2

#c73d

#5fbd

3

        db #02, #c5, #c7  ; call Lc7c5

#c740

#5fc0

4

        db #3e, #20, #37, #20

#c744

#5fc4

3

        db #02, #aa, #c7  ; call Lc7aa

#c747

#5fc7

3

        db #02, #aa, #c7  ; call Lc7aa

#c74a

#5fca

3

        db #02, #df, #c7  ; call Lc7df

#c74d

#5fcd

3

        db #02, #df, #c7  ; call Lc7df

#c750

#5fd0

3

        db #02, #df, #c7  ; call Lc7df

#c753

#5fd3

3

        db #02, #df, #c7  ; call Lc7df

#c756

#5fd6

3

        db #02, #89, #c7  ; call Lc789

#c759

#5fd9

3

        db #02, #89, #c7  ; call Lc789

#c75c

#5fdc

3

        db #02, #89, #c7  ; call Lc789

#c75f

#5fdf

3

        db #02, #89, #c7  ; call Lc789

#c762

#5fe2

3

        db #02, #c5, #c7  ; call Lc7c5

#c765

#5fe5

3

        db #02, #c5, #c7  ; call Lc7c5

#c768

#5fe8

3

        db #02, #c5, #c7  ; call Lc7c5

#c76b

#5feb

3

        db #02, #c5, #c7  ; call Lc7c5

#c76e

#5fee

3

        db #02, #c5, #c7  ; call Lc7c5

#c771

#5ff1

3

        db #02, #c5, #c7  ; call Lc7c5

#c774

#5ff4

3

        db #02, #c5, #c7  ; call Lc7c5

#c777

#5ff7

3

        db #02, #c5, #c7  ; call Lc7c5

#c77a

#5ffa

3

        db #02, #89, #c7  ; call Lc789

#c77d

#5ffd

3

        db #02, #89, #c7  ; call Lc789

#c780

#6000

3

        db #02, #89, #c7  ; call Lc789

#c783

#6003

3

        db #02, #89, #c7  ; call Lc789

#c786

#6006

3

        db #01, #02, #c7  ; jump back to the beginning

#c789

#6009

    Lc789:

#c789

#6009

16

        db #37, #10, #05, #37, #08, #04, #37, #10, #05, #37, #08, #04, #29, #08, #2e, #08

#c799

#6019

16

        db #29, #08, #2e, #08, #29, #08, #2e, #08, #29, #08, #2e, #08, #37, #08, #3e, #08

#c7a9

#6029

1

        db #06  ; ret

#c7aa

#602a

    Lc7aa:

#c7aa

#602a

11

        db #29, #10, #2e, #10, #31, #10, #37, #10, #3e, #20, #49

#c7b5

#6035

15

        db #10, #3e, #10, #45, #20, #2e, #20, #29, #10, #2e, #10, #34, #10, #2e, #10

#c7c4

#6044

1

        db #06  ; ret

#c7c5

#6045

    Lc7c5:

#c7c5

#6045

12

        db #3e, #10, #52, #08, #7c, #08, #3e, #10, #52, #08, #7c, #08

#c7d1

#6051

1

        db #06  ; ret

#c7d2

#6052

    Lc7d2:

#c7d2

#6052

12

        db #45, #10, #5d, #08, #8b, #08, #45, #10, #5d, #08, #8b, #08

#c7de

#605e

1

        db #06  ; ret

#c7df

#605f

    Lc7df:

#c7df

#605f

16

        db #29, #04, #2e, #04, #34, #04, #37, #04, #3e, #04, #45, #04, #49, #04, #52, #04

#c7ef

#606f

16

        db #5d, #04, #68, #04, #6e, #04, #7c, #04, #8b, #04, #93, #04, #a5, #04, #ba, #04

#c7ff

#607f

16

        db #29, #04, #2e, #04, #34, #04, #37, #04, #3e, #04, #45, #04, #49, #04, #52, #04

#c80f

#608f

16

        db #5d, #04, #68, #04, #6e, #04, #7c, #04, #8b, #04, #93, #04, #a5, #04, #ba, #04

#c81f

#609f

1

        db #06  ; ret

#c820

#60a0

#c820

#60a0

#c820

#60a0

    ; --------------------------------

#c820

#60a0

    Lc820_title_color_cycle:

#c820

#60a0

1

12

    c5

        push bc

#c821

#60a1

1

12

    e5

        push hl

#c822

#60a2

3

11

    21 2a 58

            ld hl, L5800_VIDEOMEM_ATTRIBUTES + 32 + 10

#c825

#60a5

3

14

    3a 33 fd

            ld a, (Lfd33_title_color)

#c828

#60a8

1

5

    3c

            inc a

#c829

#60a9

2

8

    e6 0f

            and #0f

#c82b

#60ab

3

14

    32 33 fd

            ld (Lfd33_title_color), a

#c82e

#60ae

1

5

    0f

            rrca

#c82f

#60af

2

13/8

    38 15

            jr c, Lc846

#c831

#60b1

2

8

    f6 40

            or 64

#c833

#60b3

3

11

    01 07 0c

            ld bc, #0c07  ; change the color of 12 columns and 7 rows

#c836

#60b6

    Lc836:

#c836

#60b6

1

12

    c5

            push bc

#c837

#60b7

    Lc837:

#c837

#60b7

1

8

    77

                ld (hl), a

#c838

#60b8

1

7

    23

                inc hl

#c839

#60b9

2

14/9

    10 fc

                djnz Lc837

#c83b

#60bb

1

5

    47

                ld b, a

#c83c

#60bc

2

8

    3e 14

                ld a, 20

#c83e

#60be

3

18

    cd 51 d3

                call Ld351_add_hl_a

#c841

#60c1

1

5

    78

                ld a, b

#c842

#60c2

1

11

    c1

            pop bc

#c843

#60c3

1

5

    0d

            dec c

#c844

#60c4

2

13/8

    20 f0

            jr nz, Lc836

#c846

#60c6

    Lc846:

#c846

#60c6

1

11

    e1

        pop hl

#c847

#60c7

1

11

    c1

        pop bc

#c848

#60c8

1

11

    c9

        ret

#c849

#60c9

#c849

#60c9

#c849

#60c9

    ; --------------------------------

#c849

#60c9

    ; Checks if the player has less than the maximum number of robots, and if so, jumps to the robot

#c849

#60c9

    ; construction screen with "iy" pointing to a free robot structure.

#c849

#60c9

    Lc849_robot_construction_if_possible:

#c849

#60c9

4

16

    fd 21 00 da

        ld iy, Lda00_player1_robots

#c84d

#60cd

3

11

    11 10 00

        ld de, 16

#c850

#60d0

2

8

    06 18

        ld b, MAX_ROBOTS_PER_PLAYER

#c852

#60d2

    Lc852_loop:

#c852

#60d2

3

21

    fd 7e 01

        ld a, (iy + 1)

#c855

#60d5

1

5

    b7

        or a

#c856

#60d6

2

13/8

    28 05

        jr z, Lc85d_robot_construction

#c858

#60d8

2

17

    fd 19

        add iy, de

#c85a

#60da

2

14/9

    10 f6

        djnz Lc852_loop

#c85c

#60dc

1

11

    c9

        ret

#c85d

#60dd

#c85d

#60dd

#c85d

#60dd

    ; --------------------------------

#c85d

#60dd

    ; Robot construction screen:

#c85d

#60dd

    ; input:

#c85d

#60dd

    ; - iy: pointer to the robot struct that we will be editing.

#c85d

#60dd

    Lc85d_robot_construction:

#c85d

#60dd

1

5

    f3

        di

#c85e

#60de

3

11

    21 9c d5

        ld hl, Ld59c_empty_interrupt

#c861

#60e1

3

17

    22 fe fd

        ld (Lfdfe_interrupt_pointer), hl

#c864

#60e4

1

5

    fb

        ei

#c865

#60e5

3

18

    cd b9 d0

        call Ld0b9_clear_screen

#c868

#60e8

2

8

    06 08

        ld b, 8  ; there are 8 pieces to draw

#c86a

#60ea

3

11

    11 f0 57

        ld de, #57f0  ; Video pointer: (x, y) = (128, 191)  (bottom center of the screen)

#c86d

#60ed

    Lc86d_robot_construction_draw_piece_loop:

#c86d

#60ed

1

12

    c5

        push bc

#c86e

#60ee

1

12

    d5

        push de

#c86f

#60ef

2

8

    3e 08

            ld a, 8

#c871

#60f1

1

5

    90

            sub b

#c872

#60f2

1

5

    87

            add a, a

#c873

#60f3

1

5

    87

            add a, a  ; a contains the index of the piece we want to draw in the

#c874

#60f4

                      ; Ld6c8_piece_direction_graphic_indices table

#c874

#60f4

1

5

    3c

            inc a  ; we add 1 to select the index for the south-west direction

#c875

#60f5

3

11

    21 c8 d6

            ld hl, Ld6c8_piece_direction_graphic_indices

#c878

#60f8

3

18

    cd 51 d3

            call Ld351_add_hl_a

#c87b

#60fb

1

8

    7e

            ld a, (hl)  ; get the graphic index

#c87c

#60fc

1

5

    87

            add a, a

#c87d

#60fd

1

5

    3c

            inc a

#c87e

#60fe

3

11

    21 40 d7

            ld hl, Ld740_isometric_graphic_pointers

#c881

#6101

3

18

    cd 48 d3

            call Ld348_get_ptr_from_table

#c884

#6104

1

8

    4e

            ld c, (hl)

#c885

#6105

1

7

    23

            inc hl

#c886

#6106

1

8

    46

            ld b, (hl)

#c887

#6107

1

7

    23

            inc hl

#c888

#6108

1

5

    78

            ld a, b

#c889

#6109

1

5

    87

            add a, a

#c88a

#610a

3

18

    cd 51 d3

            call Ld351_add_hl_a

#c88d

#610d

1

5

    0d

            dec c

#c88e

#610e

1

5

    79

            ld a, c

#c88f

#610f

            ; Limit the height to draw to 24 pixels (some pieces are taller than that):

#c88f

#610f

2

8

    fe 18

            cp 24

#c891

#6111

2

13/8

    38 02

            jr c, Lc895_height_calculated

#c893

#6113

2

8

    0e 18

            ld c, 24

#c895

#6115

    Lc895_height_calculated:

#c895

#6115

            ; Draw a piece sprite:

#c895

#6115

3

18

    cd 15 d3

            call Ld315_draw_masked_sprite_bottom_up

#c898

#6118

1

11

    d1

        pop de

#c899

#6119

1

11

    c1

        pop bc

#c89a

#611a

        ; move the drawing coordinates 24 pixels up:

#c89a

#611a

1

5

    7b

        ld a, e

#c89b

#611b

2

8

    d6 60

        sub 96

#c89d

#611d

1

5

    5f

        ld e, a

#c89e

#611e

2

13/8

    30 04

        jr nc, Lc8a4

#c8a0

#6120

1

5

    7a

        ld a, d

#c8a1

#6121

2

8

    d6 08

        sub 8

#c8a3

#6123

1

5

    57

        ld d, a

#c8a4

#6124

    Lc8a4:

#c8a4

#6124

2

14/9

    10 c7

        djnz Lc86d_robot_construction_draw_piece_loop

#c8a6

#6126

#c8a6

#6126

        ; Set the part of the screen where the robot under construction will be drawn to yellow:

#c8a6

#6126

3

11

    01 09 04

        ld bc, #0409

#c8a9

#6129

3

11

    21 e0 59

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + 15 * 32

#c8ac

#612c

    Lc8ac_loop_y:

#c8ac

#612c

1

12

    c5

        push bc

#c8ad

#612d

    Lc8ad_loop_x:

#c8ad

#612d

2

11

    36 46

            ld (hl), #46  ; bright, black paper, ink color 6 (yellow)

#c8af

#612f

1

7

    23

            inc hl

#c8b0

#6130

2

14/9

    10 fb

            djnz Lc8ad_loop_x

#c8b2

#6132

2

8

    3e 1c

            ld a, 28

#c8b4

#6134

3

18

    cd 51 d3

            call Ld351_add_hl_a

#c8b7

#6137

1

11

    c1

        pop bc

#c8b8

#6138

1

5

    0d

        dec c

#c8b9

#6139

2

13/8

    20 f1

        jr nz, Lc8ac_loop_y

#c8bb

#613b

#c8bb

#613b

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#c8be

#613e

        ; Script start:

#c8be

#613e

2

            db CMD_SET_SCALE, #22

#c8c0

#6140

2

            db CMD_SET_ATTRIBUTE, #47

#c8c2

#6142

3

            db CMD_SET_POSITION, #00, #03

#c8c5

#6145

5

            db "ROBOT"

#c8ca

#614a

3

            db CMD_SET_POSITION, #02, #02

#c8cd

#614d

2

            db CMD_SET_SCALE, #21

#c8cf

#614f

12

            db "CONSTRUCTION"

#c8db

#615b

2

            db CMD_SET_SCALE, #00

#c8dd

#615d

2

            db CMD_SET_ATTRIBUTE, #45

#c8df

#615f

3

            db CMD_SET_POSITION, #01, #15

#c8e2

#6162

11

            db "ELECTRONICS"

#c8ed

#616d

3

            db CMD_SET_POSITION, #04, #15

#c8f0

#6170

7

            db "NUCLEAR"

#c8f7

#6177

3

            db CMD_SET_POSITION, #07, #15

#c8fa

#617a

7

            db "PHASERS"

#c901

#6181

3

            db CMD_SET_POSITION, #0a, #15

#c904

#6184

8

            db "MISSILES"

#c90c

#618c

3

            db CMD_SET_POSITION, #0d, #15

#c90f

#618f

6

            db "CANNON"

#c915

#6195

3

            db CMD_SET_POSITION, #10, #15

#c918

#6198

9

            db "ANTI-GRAV"

#c921

#61a1

3

            db CMD_SET_POSITION, #13, #15

#c924

#61a4

6

            db "TRACKS"

#c92a

#61aa

3

            db CMD_SET_POSITION, #16, #15

#c92d

#61ad

5

            db "BIPOD"

#c932

#61b2

3

            db CMD_SET_POSITION, #15, #05

#c935

#61b5

10

            db "EXIT START"

#c93f

#61bf

1

            db CMD_NEXT_LINE

#c940

#61c0

10

            db "MENU ROBOT"

#c94a

#61ca

2

            db CMD_SET_ATTRIBUTE, #43

#c94c

#61cc

3

            db CMD_SET_POSITION, #02, #16

#c94f

#61cf

1

            db "3"

#c950

#61d0

3

            db CMD_SET_POSITION, #05, #16

#c953

#61d3

2

            db "20"

#c955

#61d5

3

            db CMD_SET_POSITION, #08, #16

#c958

#61d8

1

            db "4"

#c959

#61d9

3

            db CMD_SET_POSITION, #0b, #16

#c95c

#61dc

1

            db "4"

#c95d

#61dd

3

            db CMD_SET_POSITION, #0e, #16

#c960

#61e0

1

            db "2"

#c961

#61e1

3

            db CMD_SET_POSITION, #11, #16

#c964

#61e4

2

            db "10"

#c966

#61e6

3

            db CMD_SET_POSITION, #14, #16

#c969

#61e9

1

            db "5"

#c96a

#61ea

3

            db CMD_SET_POSITION, #17, #16

#c96d

#61ed

1

            db "3"

#c96e

#61ee

2

            db CMD_SET_SCALE, #00

#c970

#61f0

2

            db CMD_SET_ATTRIBUTE, #46

#c972

#61f2

3

            db CMD_SET_POSITION, #06, #00

#c975

#61f5

15

            db "-- RESOURCES --"

#c984

#6204

1

            db CMD_NEXT_LINE

#c985

#6205

15

            db "-- AVAILABLE --"

#c994

#6214

2

            db CMD_SET_ATTRIBUTE, #44

#c996

#6216

3

            db CMD_SET_POSITION, #09, #04

#c999

#6219

7

            db "GENERAL"

#c9a0

#6220

3

            db CMD_SET_POSITION, #0b, #00

#c9a3

#6223

11

            db "ELECTRONICS"

#c9ae

#622e

3

            db CMD_SET_POSITION, #0c, #04

#c9b1

#6231

7

            db "NUCLEAR"

#c9b8

#6238

1

            db CMD_NEXT_LINE

#c9b9

#6239

7

            db "PHASERS"

#c9c0

#6240

3

            db CMD_SET_POSITION, #0e, #03

#c9c3

#6243

8

            db "MISSILES"

#c9cb

#624b

3

            db CMD_SET_POSITION, #0f, #05

#c9ce

#624e

6

            db "CANNON"

#c9d4

#6254

3

            db CMD_SET_POSITION, #10, #04

#c9d7

#6257

7

            db "CHASSIS"

#c9de

#625e

3

            db CMD_SET_POSITION, #12, #06

#c9e1

#6261

5

            db "TOTAL"

#c9e6

#6266

1

            db CMD_END

#c9e7

#6267

        ; Script end:

#c9e7

#6267

4

21

    fd 36 08 04

        ld (iy + ROBOT_STRUCT_DIRECTION), 4  ; Robot facing south-east initially

#c9eb

#626b

4

21

    fd 36 0d 00

        ld (iy + ROBOT_STRUCT_ALTITUDE), 0

#c9ef

#626f

#c9ef

#626f

        ; Make a copy of the player resources:

#c9ef

#626f

3

11

    21 22 fd

        ld hl, Lfd22_player1_resource_counts

#c9f2

#6272

3

11

    11 29 fd

        ld de, Lfd29_resource_counts_buffer

#c9f5

#6275

3

11

    01 07 00

        ld bc, 7

#c9f8

#6278

2

23/18

    ed b0

        ldir

#c9fa

#627a

#c9fa

#627a

3

18

    cd e0 cb

        call Lcbe0_draw_resource_counts_in_construction_screen

#c9fd

#627d

3

11

    21 02 00

        ld hl, 2

#ca00

#6280

3

17

    22 1f fd

        ld (Lfd1f_cursor_position), hl  ; start in the second column, first piece ("bipod")

#ca03

#6283

1

5

    af

        xor a

#ca04

#6284

3

14

    32 21 fd

        ld (Lfd21_construction_selected_pieces), a

#ca07

#6287

3

18

    cd 1f cc

        call Lcc1f_update_selected_pieces_and_robot_preview

#ca0a

#628a

2

8

    0e 46

        ld c, COLOR_YELLOW + COLOR_BRIGHT

#ca0c

#628c

3

18

    cd a9 cb

        call Lcba9_construction_screen_set_option_color

#ca0f

#628f

    Lca0f_waiting_for_key_press_loop:

#ca0f

#628f

3

18

    cd 7c d3

        call Ld37c_read_keyboard_joystick_input

#ca12

#6292

2

8

    e6 1f

        and #1f

#ca14

#6294

        ; some key has been pressed:

#ca14

#6294

2

13/8

    28 f9

        jr z, Lca0f_waiting_for_key_press_loop

#ca16

#6296

3

17

    2a 1f fd

        ld hl, (Lfd1f_cursor_position)

#ca19

#6299

3

14

    3a 0c fd

        ld a, (Lfd0c_keyboard_state)

#ca1c

#629c

2

8

    e6 10

        and #10

#ca1e

#629e

3

11

    ca 00 cb

        jp z, Lcb00_construction_screen_move  ; Moving through the options (no space pressed)

#ca21

#62a1

        ; "fire" has been pressed:

#ca21

#62a1

1

5

    7d

        ld a, l  ; which column is the cursor in:

#ca22

#62a2

1

5

    b7

        or a

#ca23

#62a3

3

11

    ca 8e cb

        jp z, Lcb8e_construction_screen_exit  ; "fire" pressed on "exit menu" (column 0)

#ca26

#62a6

1

5

    3d

        dec a

#ca27

#62a7

3

11

    ca 52 cb

        jp z, Lcb52_construction_screen_start_robot  ; "fire" pressed on "start robot" (column 1)

#ca2a

#62aa

        ; "fire" pressed on a piece:

#ca2a

#62aa

1

5

    7c

        ld a, h  ; a = selected piece

#ca2b

#62ab

1

5

    5f

        ld e, a  ; potential optimization: no need for the ld a, h; just ld e, a; ld b, e

#ca2c

#62ac

1

5

    47

        ld b, a

#ca2d

#62ad

1

5

    04

        inc b

#ca2e

#62ae

1

5

    af

        xor a

#ca2f

#62af

1

5

    37

        scf

#ca30

#62b0

        ; get the selected piece as a one-hot representation (one bit on, all others off):

#ca30

#62b0

    Lca30_piece_to_one_hot_loop:

#ca30

#62b0

1

5

    17

        rla

#ca31

#62b1

2

14/9

    10 fd

        djnz Lca30_piece_to_one_hot_loop

#ca33

#62b3

1

5

    57

        ld d, a

#ca34

#62b4

3

14

    3a 21 fd

        ld a, (Lfd21_construction_selected_pieces)

#ca37

#62b7

1

5

    4f

        ld c, a

#ca38

#62b8

1

5

    a2

        and d  ; check if we already had that piece:

#ca39

#62b9

2

13/8

    20 69

        jr nz, Lcaa4_construction_remove_piece

#ca3b

#62bb

1

5

    7b

        ld a, e  ; e has the new selected piece

#ca3c

#62bc

2

8

    fe 03

        cp 3

#ca3e

#62be

2

13/8

    30 17

        jr nc, Lca57_construction_add_piece  ; If it's not a chassis piece, just add it

#ca40

#62c0

        ; It's a chassis piece, check if we already had one selected:

#ca40

#62c0

1

5

    79

        ld a, c  ; c still has the currently selected pieces in the robot

#ca41

#62c1

2

8

    e6 07

        and 7

#ca43

#62c3

2

13/8

    28 12

        jr z, Lca57_construction_add_piece

#ca45

#62c5

        ; Replace chassis piece:

#ca45

#62c5

1

12

    d5

        push de

#ca46

#62c6

2

8

    1e ff

            ld e, 255

#ca48

#62c8

            ; Here a = still has the currently selected pieces in the robot

#ca48

#62c8

            ; This loop gets in "e" the index of the currently selected chassis in the robot:

#ca48

#62c8

    Lca48_get_current_chassis_loop:

#ca48

#62c8

1

5

    1c

            inc e

#ca49

#62c9

1

5

    0f

            rrca

#ca4a

#62ca

2

13/8

    30 fc

            jr nc, Lca48_get_current_chassis_loop

#ca4c

#62cc

3

18

    cd c1 ca

            call Lcac1_update_resources_buffer_when_removing_a_piece

#ca4f

#62cf

            ; We remove the current chassis from the robot:

#ca4f

#62cf

1

5

    79

            ld a, c

#ca50

#62d0

2

8

    e6 f8

            and #f8

#ca52

#62d2

1

5

    4f

            ld c, a

#ca53

#62d3

3

14

    32 21 fd

            ld (Lfd21_construction_selected_pieces), a

#ca56

#62d6

1

11

    d1

        pop de

#ca57

#62d7

    Lca57_construction_add_piece:

#ca57

#62d7

1

5

    79

        ld a, c  ; c still has the currently selected pieces in the robot

#ca58

#62d8

1

5

    b2

        or d  ; we add in the new piece

#ca59

#62d9

2

8

    e6 78

        and #78

#ca5b

#62db

2

8

    fe 78

        cp #78

#ca5d

#62dd

3

11

    ca ac ca

        jp z, Lcaac_construction_beep_and_back_to_loop

#ca60

#62e0

        ; Update the resources:

#ca60

#62e0

3

11

    21 f0 ca

        ld hl, Lcaf0_piece_costs

#ca63

#62e3

1

5

    7b

        ld a, e

#ca64

#62e4

3

18

    cd 51 d3

        call Ld351_add_hl_a

#ca67

#62e7

1

8

    46

        ld b, (hl)  ; b has the piece cost

#ca68

#62e8

3

11

    21 f8 ca

        ld hl, Lcaf8_piece_factory_type

#ca6b

#62eb

1

5

    7b

        ld a, e

#ca6c

#62ec

3

18

    cd 51 d3

        call Ld351_add_hl_a

#ca6f

#62ef

1

8

    7e

        ld a, (hl)  ; a has the index of the resource to subtract from

#ca70

#62f0

3

11

    21 29 fd

        ld hl, Lfd29_resource_counts_buffer

#ca73

#62f3

3

18

    cd 51 d3

        call Ld351_add_hl_a

#ca76

#62f6

1

8

    7e

        ld a, (hl)

#ca77

#62f7

1

5

    90

        sub b

#ca78

#62f8

3

11

    d2 89 ca

        jp nc, Lca89_construction_add_piece_continue  ; If we had enough, we are good

#ca7b

#62fb

2

10

    ed 44

        neg

#ca7d

#62fd

1

5

    47

        ld b, a

#ca7e

#62fe

3

14

    3a 29 fd

        ld a, (Lfd29_resource_counts_buffer)

#ca81

#6301

1

5

    90

        sub b

#ca82

#6302

3

11

    da ac ca

        jp c, Lcaac_construction_beep_and_back_to_loop

#ca85

#6305

3

14

    32 29 fd

        ld (Lfd29_resource_counts_buffer), a

#ca88

#6308

1

5

    af

        xor a

#ca89

#6309

    Lca89_construction_add_piece_continue:

#ca89

#6309

1

8

    77

        ld (hl), a  ; update the resource counts after subtracting the piece cost

#ca8a

#630a

1

5

    79

        ld a, c

#ca8b

#630b

1

5

    b2

        or d

#ca8c

#630c

3

14

    32 21 fd

        ld (Lfd21_construction_selected_pieces), a  ; update the robot pieces

#ca8f

#630f

2

8

    3e 64

        ld a, 100

#ca91

#6311

3

18

    cd ac cc

        call Lccac_beep  ; Potential optimization: the following lines are identical to the end of the

#ca94

#6314

                         ; function below, unify.

#ca94

#6314

3

18

    cd 1f cc

        call Lcc1f_update_selected_pieces_and_robot_preview

#ca97

#6317

3

18

    cd e0 cb

        call Lcbe0_draw_resource_counts_in_construction_screen

#ca9a

#631a

    Lca9a_wait_for_fire_button_release:

#ca9a

#631a

3

18

    cd 7c d3

        call Ld37c_read_keyboard_joystick_input

#ca9d

#631d

2

8

    e6 10

        and 16

#ca9f

#631f

2

13/8

    20 f9

        jr nz, Lca9a_wait_for_fire_button_release

#caa1

#6321

3

11

    c3 4a cb

        jp Lcb4a_pause_and_back_to_construction_loop

#caa4

#6324

#caa4

#6324

#caa4

#6324

    ; --------------------------------

#caa4

#6324

    ; Removes a piece from the current robot we are editing

#caa4

#6324

    ; Input:

#caa4

#6324

    ; - e: piece to remove

#caa4

#6324

    Lcaa4_construction_remove_piece:

#caa4

#6324

3

18

    cd c1 ca

        call Lcac1_update_resources_buffer_when_removing_a_piece

#caa7

#6327

1

5

    79

        ld a, c

#caa8

#6328

1

5

    aa

        xor d

#caa9

#6329

3

14

    32 21 fd

        ld (Lfd21_construction_selected_pieces), a

#caac

#632c

    Lcaac_construction_beep_and_back_to_loop:

#caac

#632c

2

8

    3e 78

        ld a, 120

#caae

#632e

3

18

    cd ac cc

        call Lccac_beep

#cab1

#6331

3

18

    cd 1f cc

        call Lcc1f_update_selected_pieces_and_robot_preview

#cab4

#6334

3

18

    cd e0 cb

        call Lcbe0_draw_resource_counts_in_construction_screen

#cab7

#6337

    Lcab7_wait_for_fire_button_release:

#cab7

#6337

3

18

    cd 7c d3

        call Ld37c_read_keyboard_joystick_input

#caba

#633a

2

8

    e6 10

        and 16

#cabc

#633c

2

13/8

    20 f9

        jr nz, Lcab7_wait_for_fire_button_release

#cabe

#633e

3

11

    c3 4a cb

        jp Lcb4a_pause_and_back_to_construction_loop

#cac1

#6341

#cac1

#6341

#cac1

#6341

    ; --------------------------------

#cac1

#6341

    ; Update the resource counts buffer in the construction screen after removing a piece from the

#cac1

#6341

    ; robot.

#cac1

#6341

    ; Input:

#cac1

#6341

    ; - e: piece to remove

#cac1

#6341

    Lcac1_update_resources_buffer_when_removing_a_piece:

#cac1

#6341

3

11

    21 f0 ca

        ld hl, Lcaf0_piece_costs

#cac4

#6344

1

5

    7b

        ld a, e

#cac5

#6345

3

18

    cd 51 d3

        call Ld351_add_hl_a

#cac8

#6348

1

8

    46

        ld b, (hl)  ; get the cost of the piece.

#cac9

#6349

3

11

    21 f8 ca

        ld hl, Lcaf8_piece_factory_type

#cacc

#634c

1

5

    7b

        ld a, e

#cacd

#634d

3

18

    cd 51 d3

        call Ld351_add_hl_a

#cad0

#6350

1

8

    7e

        ld a, (hl)  ; Get the index in the resource counts that we should add it to.

#cad1

#6351

3

11

    21 29 fd

        ld hl, Lfd29_resource_counts_buffer

#cad4

#6354

3

18

    cd 51 d3

        call Ld351_add_hl_a

#cad7

#6357

1

8

    7e

        ld a, (hl)

#cad8

#6358

1

5

    80

        add a, b  ; Add the piece cost to the corresponding resource counts.

#cad9

#6359

1

8

    77

        ld (hl), a

#cada

#635a

        ; See if we have added more than the player had:

#cada

#635a

1

12

    e5

        push hl

#cadb

#635b

1

5

    7d

            ld a, l

#cadc

#635c

2

8

    d6 07

            sub 7  ; The actual player resource counts (Lfd22_player1_resource_counts) are just 7 bytes

#cade

#635e

                   ; offset from the buffer.

#cade

#635e

1

5

    6f

            ld l, a

#cadf

#635f

1

8

    46

            ld b, (hl)  ; Get the current resources that the player has on the index we just added to.

#cae0

#6360

1

11

    e1

        pop hl

#cae1

#6361

1

8

    7e

        ld a, (hl)

#cae2

#6362

1

5

    b8

        cp b

#cae3

#6363

1

12/6

    c8

        ret z  ; If after adding the piece cost, we still haven't reached the resources the player had

#cae4

#6364

               ; originally in that index, we are done.

#cae4

#6364

1

12/6

    d8

        ret c

#cae5

#6365

        ; Otherwise, we need to cap the resource count in this index to what the player had, and add

#cae5

#6365

        ; the rest to the general resources index (0):

#cae5

#6365

1

8

    70

        ld (hl), b

#cae6

#6366

1

5

    90

        sub b

#cae7

#6367

1

5

    47

        ld b, a

#cae8

#6368

3

14

    3a 29 fd

        ld a, (Lfd29_resource_counts_buffer)

#caeb

#636b

1

5

    80

        add a, b

#caec

#636c

3

14

    32 29 fd

        ld (Lfd29_resource_counts_buffer), a

#caef

#636f

1

11

    c9

        ret

#caf0

#6370

#caf0

#6370

#caf0

#6370

    ; --------------------------------

#caf0

#6370

    ; How much does each piece cost: bipod, tracks, anti-grav, cannon, missiles, phasers, nuclear,

#caf0

#6370

    ; electronics:

#caf0

#6370

    Lcaf0_piece_costs:

#caf0

#6370

8

        db 3, 5, 10, 2, 4, 4, 20, 3

#caf8

#6378

#caf8

#6378

    ; Which factory type produces resources for each piece:

#caf8

#6378

    ; - bipod, tracks, anti-grav are all produced in the "chassis" factory types (6), whereas the other

#caf8

#6378

    ;   pieces.

#caf8

#6378

    ;   have dedicated factories for themselves.

#caf8

#6378

    Lcaf8_piece_factory_type:

#caf8

#6378

8

        db 6, 6, 6, 5, 4, 3, 2, 1

#cb00

#6380

#cb00

#6380

#cb00

#6380

    ; --------------------------------

#cb00

#6380

    ; Moves the cursor around the construction screen after pressing one of the direction keys

#cb00

#6380

    ; Input:

#cb00

#6380

    ; - h: cursor row (selected piece if column == 2)

#cb00

#6380

    ; - l: cursor column

#cb00

#6380

    Lcb00_construction_screen_move:

#cb00

#6380

3

14

    3a 0c fd

        ld a, (Lfd0c_keyboard_state)

#cb03

#6383

2

8

    e6 03

        and 3

#cb05

#6385

2

13/8

    28 14

        jr z, Lcb1b_construction_screen_move_up_down

#cb07

#6387

1

5

    4f

        ld c, a

#cb08

#6388

1

5

    7d

        ld a, l

#cb09

#6389

2

10

    cb 19

        rr c

#cb0b

#638b

2

13/8

    30 01

        jr nc, Lcb0e_right_not_pressed

#cb0d

#638d

1

5

    3c

        inc a

#cb0e

#638e

    Lcb0e_right_not_pressed:

#cb0e

#638e

2

10

    cb 19

        rr c

#cb10

#6390

2

13/8

    30 01

        jr nc, Lcb13_left_not_pressed

#cb12

#6392

1

5

    3d

        dec a

#cb13

#6393

    Lcb13_left_not_pressed:

#cb13

#6393

2

8

    fe 03

        cp 3  ; make sure we did not move out of bounds

#cb15

#6395

2

13/8

    30 33

        jr nc, Lcb4a_pause_and_back_to_construction_loop

#cb17

#6397

1

5

    6f

        ld l, a  ; l = new cursor column

#cb18

#6398

3

11

    c3 36 cb

        jp Lcb36_construction_screen_update_color_of_selected_option_after_move

#cb1b

#639b

#cb1b

#639b

    Lcb1b_construction_screen_move_up_down:

#cb1b

#639b

3

14

    3a 0c fd

        ld a, (Lfd0c_keyboard_state)

#cb1e

#639e

        ; Rotate the keyboard state to get to the bits representing up/down

#cb1e

#639e

1

5

    0f

        rrca

#cb1f

#639f

1

5

    0f

        rrca

#cb20

#63a0

1

5

    4f

        ld c, a

#cb21

#63a1

1

5

    7d

        ld a, l

#cb22

#63a2

2

8

    fe 02

        cp 2  ; If we are not on the pieces column, just return as we cannot move up/down:

#cb24

#63a4

2

13/8

    20 24

        jr nz, Lcb4a_pause_and_back_to_construction_loop

#cb26

#63a6

1

5

    7c

        ld a, h

#cb27

#63a7

2

10

    cb 19

        rr c

#cb29

#63a9

2

13/8

    30 01

        jr nc, Lcb2c_up_not_pressed

#cb2b

#63ab

1

5

    3d

        dec a  ; move up

#cb2c

#63ac

    Lcb2c_up_not_pressed:

#cb2c

#63ac

2

10

    cb 19

        rr c

#cb2e

#63ae

2

13/8

    30 01

        jr nc, Lcb31_down_not_pressed

#cb30

#63b0

1

5

    3c

        inc a  ; move down

#cb31

#63b1

    Lcb31_down_not_pressed:

#cb31

#63b1

2

8

    fe 08

        cp 8  ; make sure we did not move out of bounds

#cb33

#63b3

2

13/8

    30 15

        jr nc, Lcb4a_pause_and_back_to_construction_loop

#cb35

#63b5

1

5

    67

        ld h, a  ; h = new cursor row

#cb36

#63b6

    Lcb36_construction_screen_update_color_of_selected_option_after_move:

#cb36

#63b6

1

12

    e5

        push hl

#cb37

#63b7

2

8

    0e 45

            ld c, COLOR_CYAN + COLOR_BRIGHT

#cb39

#63b9

3

18

    cd a9 cb

            call Lcba9_construction_screen_set_option_color

#cb3c

#63bc

1

11

    e1

        pop hl

#cb3d

#63bd

3

17

    22 1f fd

        ld (Lfd1f_cursor_position), hl

#cb40

#63c0

2

8

    0e 46

        ld c, COLOR_YELLOW + COLOR_BRIGHT

#cb42

#63c2

3

18

    cd a9 cb

        call Lcba9_construction_screen_set_option_color

#cb45

#63c5

2

8

    3e 14

        ld a, 20

#cb47

#63c7

3

18

    cd ac cc

        call Lccac_beep

#cb4a

#63ca

#cb4a

#63ca

    Lcb4a_pause_and_back_to_construction_loop:

#cb4a

#63ca

2

8

    06 0a

        ld b, 10

#cb4c

#63cc

    Lcb4c_pause_loop:

#cb4c

#63cc

1

5

    76

        halt

#cb4d

#63cd

2

14/9

    10 fd

        djnz Lcb4c_pause_loop

#cb4f

#63cf

3

11

    c3 0f ca

        jp Lca0f_waiting_for_key_press_loop

#cb52

#63d2

#cb52

#63d2

#cb52

#63d2

    ; --------------------------------

#cb52

#63d2

    Lcb52_construction_screen_start_robot:

#cb52

#63d2

3

14

    3a 21 fd

        ld a, (Lfd21_construction_selected_pieces)

#cb55

#63d5

1

5

    4f

        ld c, a

#cb56

#63d6

2

8

    e6 07

        and 7

#cb58

#63d8

2

13/8

    28 f0

        jr z, Lcb4a_pause_and_back_to_construction_loop  ; If we have not selected any piece, do not

#cb5a

#63da

                                                         ; allow the robot to start

#cb5a

#63da

1

5

    79

        ld a, c

#cb5b

#63db

2

8

    e6 78

        and #78

#cb5d

#63dd

2

13/8

    28 eb

        jr z, Lcb4a_pause_and_back_to_construction_loop  ; If we have not selected any weapon, do not

#cb5f

#63df

                                                         ; allow the robot to start

#cb5f

#63df

3

11

    21 29 fd

        ld hl, Lfd29_resource_counts_buffer

#cb62

#63e2

3

11

    11 22 fd

        ld de, Lfd22_player1_resource_counts

#cb65

#63e5

3

11

    01 07 00

        ld bc, 7

#cb68

#63e8

2

23/18

    ed b0

        ldir  ; copy the resource buffer (that has the price of the robot discounted) to the player

#cb6a

#63ea

              ; resources

#cb6a

#63ea

3

17

    2a 0e fd

        ld hl, (Lfd0e_player_x)

#cb6d

#63ed

3

14

    3a 0d fd

        ld a, (Lfd0d_player_y)

#cb70

#63f0

2

8

    c6 04

        add a, 4

#cb72

#63f2

1

5

    47

        ld b, a  ; robot starts 4 positions off the player in the y axis to be placed at the entrance

#cb73

#63f3

                 ; of the factory

#cb73

#63f3

4

21

    fd 36 0a 00

        ld (iy + ROBOT_STRUCT_CONTROL), ROBOT_CONTROL_AUTO

#cb77

#63f7

3

18

    cd 7c cc

        call Lcc7c_set_robot_position

#cb7a

#63fa

3

14

    3a 21 fd

        ld a, (Lfd21_construction_selected_pieces)

#cb7d

#63fd

3

21

    fd 77 07

        ld (iy + ROBOT_STRUCT_PIECES), a

#cb80

#6400

        ; Make the sound corresponding to having created a robot:

#cb80

#6400

2

8

    06 50

        ld b, 80

#cb82

#6402

    Lcb82_sound_loop:

#cb82

#6402

1

5

    78

        ld a, b

#cb83

#6403

3

18

    cd ac cc

        call Lccac_beep

#cb86

#6406

1

5

    78

        ld a, b

#cb87

#6407

2

8

    d6 05

        sub 5

#cb89

#6409

1

5

    47

        ld b, a

#cb8a

#640a

2

8

    fe 14

        cp 20

#cb8c

#640c

2

13/8

    30 f4

        jr nc, Lcb82_sound_loop

#cb8e

#640e

        ; And then just exit the construction screen:

#cb8e

#640e

        ; jp Lcb8e_construction_screen_exit

#cb8e

#640e

#cb8e

#640e

#cb8e

#640e

    ; --------------------------------

#cb8e

#640e

    Lcb8e_construction_screen_exit:

#cb8e

#640e

2

8

    3e c8

        ld a, 200

#cb90

#6410

3

18

    cd ac cc

        call Lccac_beep  ; make a sound

#cb93

#6413

2

8

    3e 05

        ld a, 5

#cb95

#6415

3

14

    32 30 fd

        ld (Lfd30_player_elevate_timer), a  ; make the player levitate a bit after exiting

#cb98

#6418

2

17

    fd e5

        push iy

#cb9a

#641a

3

18

    cd fe cf

            call Lcffe_clear_5b00_buffer  ; clear the screen buffer

#cb9d

#641d

3

18

    cd ca d0

            call Ld0ca_draw_in_game_screen_and_hud

#cba0

#6420

2

16

    fd e1

        pop iy

#cba2

#6422

        ; Restore the in-game interrupt (which was deactivated in the construction screen):

#cba2

#6422

3

11

    21 66 d5

        ld hl, Ld566_interrupt

#cba5

#6425

3

17

    22 fe fd

        ld (Lfdfe_interrupt_pointer), hl

#cba8

#6428

1

11

    c9

        ret

#cba9

#6429

#cba9

#6429

#cba9

#6429

    ; --------------------------------

#cba9

#6429

    ; input:

#cba9

#6429

    ; - (Lfd1f_cursor_position): option to change the color

#cba9

#6429

    ; - c: color to set

#cba9

#6429

    Lcba9_construction_screen_set_option_color:

#cba9

#6429

3

17

    2a 1f fd

        ld hl, (Lfd1f_cursor_position)

#cbac

#642c

1

5

    7d

        ld a, l

#cbad

#642d

2

8

    fe 02

        cp 2  ; if cursor is in column "2' (the piece names)

#cbaf

#642f

2

13/8

    28 15

        jr z, Lcbc6_set_attribute_piece_name

#cbb1

#6431

1

5

    87

        add a, a

#cbb2

#6432

1

5

    85

        add a, l

#cbb3

#6433

1

5

    87

        add a, a

#cbb4

#6434

2

8

    c6 a4

        add a, 164

#cbb6

#6436

1

5

    6f

        ld l, a  ; l = a*6 + 5*32 + 4

#cbb7

#6437

2

8

    26 5a

        ld h, #5a  ; Here, if a == 0, we will change the color of the "EXIT MENU" option, and if a ==

#cbb9

#6439

                   ; 1, of the "START ROBOT" option.

#cbb9

#6439

2

8

    06 05

        ld b, 5

#cbbb

#643b

3

18

    cd db cb

        call Lcbdb_set_attribute_loop  ; change color of the first line

#cbbe

#643e

1

5

    7d

        ld a, l

#cbbf

#643f

2

8

    c6 1b

        add a, 27

#cbc1

#6441

1

5

    6f

        ld l, a

#cbc2

#6442

2

8

    06 05

        ld b, 5

#cbc4

#6444

2

13

    18 15

        jr Lcbdb_set_attribute_loop  ; change color of the second line

#cbc6

#6446

#cbc6

#6446

    Lcbc6_set_attribute_piece_name:

#cbc6

#6446

        ; Calculate the position of the "h"-th piece name and paint it with color "c"

#cbc6

#6446

1

5

    7c

        ld a, h

#cbc7

#6447

1

5

    87

        add a, a

#cbc8

#6448

1

5

    84

        add a, h  ; a = h*3

#cbc9

#6449

2

10

    ed 44

        neg  ; a = -h*3

#cbcb

#644b

2

8

    c6 16

        add a, 22  ; a = 22 - h*3

#cbcd

#644d

1

5

    87

        add a, a

#cbce

#644e

1

5

    87

        add a, a

#cbcf

#644f

1

5

    87

        add a, a  ; a = 8*(22 - h*3)

#cbd0

#6450

1

5

    6f

        ld l, a

#cbd1

#6451

2

8

    26 00

        ld h, 0

#cbd3

#6453

1

12

    29

        add hl, hl

#cbd4

#6454

1

12

    29

        add hl, hl  ; hl = 32 * (22 - h*3)

#cbd5

#6455

3

11

    11 15 58

        ld de, L5800_VIDEOMEM_ATTRIBUTES + 21

#cbd8

#6458

1

12

    19

        add hl, de  ; hl = L5800_VIDEOMEM_ATTRIBUTES + 21 + 32 * (22 - h*3)

#cbd9

#6459

        ; set the attribute for 11 characters in a row (which is the length of the larger piece name

#cbd9

#6459

        ; "electronics"):

#cbd9

#6459

2

8

    06 0b

        ld b, 11

#cbdb

#645b

        ; set "b" positions in the attribute table to attribute "c":

#cbdb

#645b

    Lcbdb_set_attribute_loop:

#cbdb

#645b

1

8

    71

        ld (hl), c

#cbdc

#645c

1

7

    23

        inc hl

#cbdd

#645d

2

14/9

    10 fc

        djnz Lcbdb_set_attribute_loop

#cbdf

#645f

1

11

    c9

        ret

#cbe0

#6460

#cbe0

#6460

#cbe0

#6460

    ; --------------------------------

#cbe0

#6460

    Lcbe0_draw_resource_counts_in_construction_screen:

#cbe0

#6460

3

11

    11 29 fd

        ld de, Lfd29_resource_counts_buffer

#cbe3

#6463

3

11

    21 00 00

        ld hl, 0  ; hl will accumulate total resources

#cbe6

#6466

2

8

    0e 09

        ld c, 9  ; start y coordinate to draw resource counts

#cbe8

#6468

2

8

    06 07

        ld b, 7

#cbea

#646a

    Lcbea:

#cbea

#646a

1

8

    1a

        ld a, (de)

#cbeb

#646b

3

18

    cd 51 d3

        call Ld351_add_hl_a

#cbee

#646e

1

8

    1a

        ld a, (de)

#cbef

#646f

3

18

    cd 08 cc

        call Lcc08_draw_single_resource_count_in_construction_screen

#cbf2

#6472

1

7

    13

        inc de

#cbf3

#6473

1

5

    0c

        inc c

#cbf4

#6474

1

5

    78

        ld a, b

#cbf5

#6475

2

8

    fe 07

        cp 7

#cbf7

#6477

2

13/8

    20 01

        jr nz, Lcbfa

#cbf9

#6479

1

5

    0c

        inc c  ; the fist time, we leave a blank space between general resources and the rest

#cbfa

#647a

    Lcbfa:

#cbfa

#647a

2

14/9

    10 ee

        djnz Lcbea

#cbfc

#647c

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#cbff

#647f

        ; script start:

#cbff

#647f

3

            db CMD_SET_POSITION, #12, #0c

#cc02

#6482

1

            db CMD_END

#cc03

#6483

        ; script end:

#cc03

#6483

2

8

    1e 20

        ld e, " "

#cc05

#6485

3

11

    c3 01 d4

        jp Ld401_render_16bit_number_3digits  ; render the sum of all resources

#cc08

#6488

#cc08

#6488

#cc08

#6488

    ; --------------------------------

#cc08

#6488

    Lcc08_draw_single_resource_count_in_construction_screen:

#cc08

#6488

1

12

    f5

        push af

#cc09

#6489

1

5

    79

            ld a, c

#cc0a

#648a

3

14

    32 11 cc

            ld (Lcc11_selfmodifying), a  ; set the desired y coordinate

#cc0d

#648d

3

18

    cd 2d d4

            call Ld42d_execute_ui_script

#cc10

#6490

            ; script start:

#cc10

#6490

1

                db CMD_SET_POSITION

#cc11

#6491

    Lcc11_selfmodifying:

#cc11

#6491

2

                db #00, #0d

#cc13

#6493

1

                db CMD_END

#cc14

#6494

            ; script end:

#cc14

#6494

1

11

    f1

        pop af

#cc15

#6495

1

12

    c5

        push bc

#cc16

#6496

1

12

    d5

        push de

#cc17

#6497

1

12

    e5

        push hl

#cc18

#6498

3

18

    cd e5 d3

            call Ld3e5_render_8bit_number

#cc1b

#649b

1

11

    e1

        pop hl

#cc1c

#649c

1

11

    d1

        pop de

#cc1d

#649d

1

11

    c1

        pop bc

#cc1e

#649e

1

11

    c9

        ret

#cc1f

#649f

#cc1f

#649f

#cc1f

#649f

    ; --------------------------------

#cc1f

#649f

    ; - Paints the selected pieces in white

#cc1f

#649f

    ; - those not selected in yellow

#cc1f

#649f

    ; - synthesizes the robot preview and draws it to screen

#cc1f

#649f

    ; input:

#cc1f

#649f

    ; - iy: robot struct pointer

#cc1f

#649f

    Lcc1f_update_selected_pieces_and_robot_preview:

#cc1f

#649f

3

11

    21 10 58

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + 16

#cc22

#64a2

3

14

    3a 21 fd

        ld a, (Lfd21_construction_selected_pieces)

#cc25

#64a5

1

5

    4f

        ld c, a

#cc26

#64a6

2

8

    06 08

        ld b, 8  ; 8 pieces

#cc28

#64a8

        ; paint the selected pieces in white color, and non-selected in yellow:

#cc28

#64a8

    Lcc28_loop_piece:

#cc28

#64a8

2

8

    1e 06

        ld e, COLOR_YELLOW

#cc2a

#64aa

2

10

    cb 11

        rl c

#cc2c

#64ac

2

13/8

    30 02

        jr nc, Lcc30

#cc2e

#64ae

2

8

    1e 47

        ld e, COLOR_BRIGHT + COLOR_WHITE

#cc30

#64b0

    Lcc30:

#cc30

#64b0

1

12

    c5

        push bc

#cc31

#64b1

3

11

    01 03 04

            ld bc, #0403

#cc34

#64b4

    Lcc34_loop_y:

#cc34

#64b4

1

12

    c5

            push bc

#cc35

#64b5

    Lcc35_loop_x:

#cc35

#64b5

1

8

    73

                ld (hl), e

#cc36

#64b6

1

7

    23

                inc hl

#cc37

#64b7

2

14/9

    10 fc

                djnz Lcc35_loop_x

#cc39

#64b9

2

8

    3e 1c

                ld a, 28  ; next line

#cc3b

#64bb

3

18

    cd 51 d3

                call Ld351_add_hl_a

#cc3e

#64be

1

11

    c1

            pop bc

#cc3f

#64bf

1

5

    0d

            dec c

#cc40

#64c0

2

13/8

    20 f2

            jr nz, Lcc34_loop_y

#cc42

#64c2

1

11

    c1

        pop bc

#cc43

#64c3

2

14/9

    10 e3

        djnz Lcc28_loop_piece

#cc45

#64c5

#cc45

#64c5

3

18

    cd fe cf

        call Lcffe_clear_5b00_buffer

#cc48

#64c8

3

14

    3a 21 fd

        ld a, (Lfd21_construction_selected_pieces)

#cc4b

#64cb

3

21

    fd 77 07

        ld (iy + ROBOT_STRUCT_PIECES), a

#cc4e

#64ce

3

11

    11 07 0a

        ld de, #0a07  ; isometric coordinates of the robot, so it shows up in the right place in the

#cc51

#64d1

                      ; screen.

#cc51

#64d1

3

18

    cd e8 ce

        call Lcee8_draw_robot_to_buffer

#cc54

#64d4

3

14

    3a 3f cf

        ld a, (Lcf3f_selfmodifying_sprite_elevation)

#cc57

#64d7

3

21

    fd 77 09

        ld (iy + ROBOT_STRUCT_HEIGHT), a

#cc5a

#64da

        ; Copies a block of 32*48 pixels from #6168 to (0,120) in video memory: this is the preview of

#cc5a

#64da

        ; the robot being constructed.

#cc5a

#64da

3

11

    01 48 04

        ld bc, #0448

#cc5d

#64dd

3

11

    11 68 61

        ld de, #6168

#cc60

#64e0

3

11

    21 e0 48

        ld hl, L4000_VIDEOMEM_PATTERNS + #08e0  ; (x, y) = (0, 120)

#cc63

#64e3

    Lcc63_loop_y:

#cc63

#64e3

1

12

    c5

        push bc

#cc64

#64e4

1

12

    e5

            push hl

#cc65

#64e5

    Lcc65_loop_x:

#cc65

#64e5

1

8

    1a

                ld a, (de)

#cc66

#64e6

1

8

    77

                ld (hl), a

#cc67

#64e7

1

7

    13

                inc de

#cc68

#64e8

1

7

    23

                inc hl

#cc69

#64e9

2

14/9

    10 fa

                djnz Lcc65_loop_x

#cc6b

#64eb

1

5

    7b

                ld a, e

#cc6c

#64ec

2

8

    c6 10

                add a, 16

#cc6e

#64ee

1

5

    5f

                ld e, a

#cc6f

#64ef

1

5

    7a

                ld a, d

#cc70

#64f0

2

8

    ce 00

                adc a, 0

#cc72

#64f2

1

5

    57

                ld d, a

#cc73

#64f3

1

11

    e1

            pop hl

#cc74

#64f4

3

18

    cd 2a d3

            call Ld32a_inc_video_ptr_y_hl

#cc77

#64f7

1

11

    c1

        pop bc

#cc78

#64f8

1

5

    0d

        dec c

#cc79

#64f9

2

13/8

    20 e8

        jr nz, Lcc63_loop_y

#cc7b

#64fb

1

11

    c9

        ret

#cc7c

#64fc

#cc7c

#64fc

#cc7c

#64fc

    ; --------------------------------

#cc7c

#64fc

    ; Input:

#cc7c

#64fc

    ; - hl: x coordinate

#cc7c

#64fc

    ; - b: y coordinate

#cc7c

#64fc

    Lcc7c_set_robot_position:

#cc7c

#64fc

3

21

    fd 75 02

        ld (iy + ROBOT_STRUCT_X), l

#cc7f

#64ff

3

21

    fd 74 03

        ld (iy + ROBOT_STRUCT_X + 1), h

#cc82

#6502

3

21

    fd 70 04

        ld (iy + ROBOT_STRUCT_Y), b

#cc85

#6505

1

12

    e5

        push hl

#cc86

#6506

1

5

    78

            ld a, b

#cc87

#6507

3

18

    cd a6 cc

            call Lcca6_compute_map_ptr

#cc8a

#650a

3

21

    fd 75 00

            ld (iy + ROBOT_STRUCT_MAP_PTR), l

#cc8d

#650d

3

21

    fd 74 01

            ld (iy + ROBOT_STRUCT_MAP_PTR + 1), h

#cc90

#6510

2

17

    cb f6

            set 6, (hl)

#cc92

#6512

1

11

    e1

        pop hl

#cc93

#6513

3

21

    fd 4e 04

        ld c, (iy + ROBOT_STRUCT_Y)

#cc96

#6516

3

21

    fd 7e 0a

        ld a, (iy + ROBOT_STRUCT_CONTROL)

#cc99

#6519

1

5

    07

        rlca

#cc9a

#651a

2

8

    e6 01

        and 1

#cc9c

#651c

1

5

    47

        ld b, a  ; b = 0 if player robot, and b = 1 if enemy robot.

#cc9d

#651d

3

11

    c3 5a d6

        jp Ld65a_flip_2x2_radar_area

#cca0

#6520

#cca0

#6520

#cca0

#6520

    ; --------------------------------

#cca0

#6520

    ; Computes the pointer in the map corresponding to the current x, y coordinates of the player.

#cca0

#6520

    Lcca0_compute_player_map_ptr:

#cca0

#6520

3

17

    2a 0e fd

        ld hl, (Lfd0e_player_x)

#cca3

#6523

3

14

    3a 0d fd

        ld a, (Lfd0d_player_y)

#cca6

#6526

        ; jp Lcca6_compute_map_ptr

#cca6

#6526

#cca6

#6526

#cca6

#6526

    ; --------------------------------

#cca6

#6526

    ; Computes the pointer in the map corresponding to some x, y coordinates.

#cca6

#6526

    ; Input:

#cca6

#6526

    ; - hl: x

#cca6

#6526

    ; - a: y

#cca6

#6526

    ; Output:

#cca6

#6526

    ; - hl: map ptr

#cca6

#6526

    Lcca6_compute_map_ptr:

#cca6

#6526

1

5

    87

        add a, a

#cca7

#6527

2

8

    c6 dd

        add a, #dd

#cca9

#6529

1

5

    84

        add a, h

#ccaa

#652a

1

5

    67

        ld h, a  ; h += a*2 + #dd

#ccab

#652b

1

11

    c9

        ret

#ccac

#652c

#ccac

#652c

#ccac

#652c

    ; --------------------------------

#ccac

#652c

    ; Produces a beep sound.

#ccac

#652c

    ; input:

#ccac

#652c

    ; - a: sound period (lower means higher pitch)

#ccac

#652c

    Lccac_beep:

#ccac

#652c

1

12

    c5

        push bc

#ccad

#652d

1

5

    47

            ld b, a

#ccae

#652e

1

5

    af

            xor a

#ccaf

#652f

1

5

    4f

            ld c, a

#ccb0

#6530

    Lccb0_beep_outer_loop:

#ccb0

#6530

1

12

    c5

            push bc

#ccb1

#6531

2

8

    ee 10

                xor 16

#ccb3

#6533

2

12

    d3 fe

                out (ULA_PORT), a  ; change MIC/EAR state (to produce sound)

#ccb5

#6535

    Lccb5_inner_loop:

#ccb5

#6535

2

14/9

    10 fe

                djnz Lccb5_inner_loop

#ccb7

#6537

1

11

    c1

            pop bc

#ccb8

#6538

1

5

    0d

            dec c

#ccb9

#6539

2

13/8

    20 f5

            jr nz, Lccb0_beep_outer_loop

#ccbb

#653b

1

11

    c1

        pop bc

#ccbc

#653c

1

11

    c9

        ret

#ccbd

#653d

#ccbd

#653d

#ccbd

#653d

    ; --------------------------------

#ccbd

#653d

    ; Clears the double buffer, draws the game area there, and copies it to the video memory.

#ccbd

#653d

    Lccbd_redraw_game_area:

#ccbd

#653d

3

18

    cd d7 cf

        call Lcfd7_draw_blank_map_in_buffer

#ccc0

#6540

3

18

    cd c6 cc

        call Lccc6_draw_map_to_buffer

#ccc3

#6543

3

11

    c3 71 d0

        jp Ld071_copy_game_area_buffer_to_screen

#ccc6

#6546

#ccc6

#6546

#ccc6

#6546

    ; --------------------------------

#ccc6

#6546

    ; Renders the player and the map to the buffer

#ccc6

#6546

    Lccc6_draw_map_to_buffer:

#ccc6

#6546

3

11

    21 00 00

        ld hl, 0

#ccc9

#6549

3

17

    22 11 fd

        ld (Lfd11_player_iso_coordinates_if_deferred), hl  ; mark that the player rendering is not

#cccc

#654c

                                                           ; deferred.

#cccc

#654c

        ; Draw the player shadow:

#cccc

#654c

1

5

    af

        xor a

#cccd

#654d

3

14

    32 3f cf

        ld (Lcf3f_selfmodifying_sprite_elevation), a

#ccd0

#6550

3

17

    2a 0e fd

        ld hl, (Lfd0e_player_x)

#ccd3

#6553

4

22

    ed 5b 06 fd

        ld de, (Lfd06_scroll_ptr)

#ccd7

#6557

1

5

    7a

        ld a, d

#ccd8

#6558

2

8

    e6 01

        and #01

#ccda

#655a

1

5

    57

        ld d, a  ; keep only the lower 9 bits of (Lfd06_scroll_ptr), which contain the x coordinate

#ccdb

#655b

1

5

    af

        xor a

#ccdc

#655c

2

17

    ed 52

        sbc hl, de  ; hl = player_x - scroll_x

#ccde

#655e

1

5

    5d

        ld e, l

#ccdf

#655f

3

14

    3a 0d fd

        ld a, (Lfd0d_player_y)

#cce2

#6562

1

5

    57

        ld d, a

#cce3

#6563

2

8

    3e 01

        ld a, 1  ; draw graphic 1 (player shadow)

#cce5

#6565

3

18

    cd 2d cf

        call Lcf2d_draw_sprite_to_buffer

#cce8

#6568

#cce8

#6568

3

17

    2a 06 fd

        ld hl, (Lfd06_scroll_ptr)

#cceb

#656b

2

8

    3e 20

        ld a, 32

#cced

#656d

3

18

    cd 51 d3

        call Ld351_add_hl_a

#ccf0

#6570

3

11

    11 20 00

        ld de, 32

#ccf3

#6573

        ; Draw the visible part of the map:

#ccf3

#6573

        ; - "de" starts at 32 and decrements at each loop, and keeps track of the visible area we need

#ccf3

#6573

        ;   to draw.

#ccf3

#6573

    Lccf3_outer_loop:

#ccf3

#6573

1

7

    2b

        dec hl

#ccf4

#6574

1

5

    1d

        dec e

#ccf5

#6575

1

12

    e5

        push hl

#ccf6

#6576

1

12

    d5

        push de

#ccf7

#6577

            ; Each inner iteration represents a diagonal row of the map (horizontal when projected to

#ccf7

#6577

            ; the screen).

#ccf7

#6577

            ; - So, if a row starts in (7,0), it will draw: (7,0), (8,1), (9,2), etc.

#ccf7

#6577

            ; - In the first iteration, it'll draw the objects that appear in the top of the screen.

#ccf7

#6577

            ; - In subsequent iterations it goes down one row every time.

#ccf7

#6577

            ; - In the first iteration of the outer loop "e" will go from 31 -> 32, then from 30 -> 32,

#ccf7

#6577

            ;   29 -> 32, etc.

#ccf7

#6577

            ; - until we reach 15 -> 31, 14 -> 30, etc. as at most the inner loop loops 16 times (

#ccf7

#6577

            ;   controlled by "d").

#ccf7

#6577

            ; - This is to capture the visible part of the screen with the isometric projection.

#ccf7

#6577

    Lccf7_inner_loop:

#ccf7

#6577

1

5

    7b

            ld a, e

#ccf8

#6578

1

5

    b7

            or a

#ccf9

#6579

3

11

    fa 01 cd

            jp m, Lcd01_not_visible  ; if we are outside of the visible area, skip

#ccfc

#657c

1

8

    7e

            ld a, (hl)

#ccfd

#657d

1

5

    b7

            or a

#ccfe

#657e

3

18/11

    c4 18 cd

            call nz, Lcd18_draw_map_cell  ; If there is anything in the map, draw it!

#cd01

#6581

    Lcd01_not_visible:

#cd01

#6581

            ; move to the next position of the map to draw:

#cd01

#6581

1

5

    24

            inc h  ; This does "y++" (since each row is 512 bytes long)

#cd02

#6582

1

5

    24

            inc h

#cd03

#6583

1

7

    23

            inc hl  ; This does "x++". Potential optimization: "inc l"?

#cd04

#6584

1

5

    14

            inc d  ; keep track of how many positions we have drawn in this outer loop iteration

#cd05

#6585

1

5

    1c

            inc e

#cd06

#6586

1

5

    7a

            ld a, d

#cd07

#6587

2

8

    fe 10

            cp 16

#cd09

#6589

2

13/8

    30 05

            jr nc, Lcd10_exit_inner_loop  ; If we have done 16 iterations of the inner loop, end

#cd0b

#658b

1

5

    7b

            ld a, e

#cd0c

#658c

2

8

    fe 20

            cp 32  ; if we have reached the limit visible in the screen, we are done.

#cd0e

#658e

2

13/8

    20 e7

            jr nz, Lccf7_inner_loop

#cd10

#6590

    Lcd10_exit_inner_loop:

#cd10

#6590

1

5

    7b

            ld a, e

#cd11

#6591

1

11

    d1

        pop de

#cd12

#6592

1

11

    e1

        pop hl

#cd13

#6593

2

8

    fe 01

        cp 1  ; when after drawing one row, "e == 1", end, which means there is no chance of anything

#cd15

#6595

              ; visible any more in subsequent outer loop iterations.

#cd15

#6595

2

13/8

    20 dc

        jr nz, Lccf3_outer_loop

#cd17

#6597

1

11

    c9

        ret

#cd18

#6598

#cd18

#6598

#cd18

#6598

    ; --------------------------------

#cd18

#6598

    ; Draws whatever is in this map cell: map elements, robots, player, etc.

#cd18

#6598

    ; Input:

#cd18

#6598

    ; - hl: map ptr

#cd18

#6598

    Lcd18_draw_map_cell:

#cd18

#6598

        ; Start by drawing the map element in this position, if any:

#cd18

#6598

1

12

    e5

        push hl

#cd19

#6599

1

12

    d5

        push de

#cd1a

#659a

1

12

    f5

        push af

#cd1b

#659b

2

10

    cb 6f

            bit 5, a  ; Map elements occupy a 2x2 block in the map, but only the bottom-left corner has

#cd1d

#659d

                      ; bit 5 == 0.

#cd1d

#659d

2

13/8

    20 0c

            jr nz, Lcd2b_skip_map_element_draw

#cd1f

#659f

2

8

    e6 1f

            and #1f  ; If there is no map element in this position, skip.

#cd21

#65a1

2

13/8

    28 08

            jr z, Lcd2b_skip_map_element_draw

#cd23

#65a3

3

11

    21 3f cf

            ld hl, Lcf3f_selfmodifying_sprite_elevation

#cd26

#65a6

2

11

    36 00

            ld (hl), 0

#cd28

#65a8

3

18

    cd 2d cf

            call Lcf2d_draw_sprite_to_buffer

#cd2b

#65ab

    Lcd2b_skip_map_element_draw:

#cd2b

#65ab

1

11

    f1

        pop af

#cd2c

#65ac

1

11

    d1

        pop de

#cd2d

#65ad

1

11

    e1

        pop hl

#cd2e

#65ae

        ; Now check if there is an object here (robot, etc.):

#cd2e

#65ae

2

10

    cb 77

        bit 6, a  ; objects are marked with bit 6

#cd30

#65b0

3

18/11

    c4 12 ce

        call nz, Lce12_draw_object_to_map

#cd33

#65b3

1

8

    7e

        ld a, (hl)

#cd34

#65b4

2

10

    cb 7f

        bit 7, a  ; the player is marked with bit 7

#cd36

#65b6

1

12/6

    c8

        ret z  ; player is not here

#cd37

#65b7

        ; Draw the player:

#cd37

#65b7

4

22

    ed 4b 11 fd

        ld bc, (Lfd11_player_iso_coordinates_if_deferred)

#cd3b

#65bb

1

5

    78

        ld a, b

#cd3c

#65bc

1

5

    b1

        or c

#cd3d

#65bd

2

13/8

    20 3a

        jr nz, Lcd79_player_rendering_was_deferred  ; player rendering was already deferred.

#cd3f

#65bf

        ; Check if there is a map element that would occlude the player sprite when it shouldn't,

#cd3f

#65bf

        ; and defer player rendering if so:

#cd3f

#65bf

1

12

    d5

        push de

#cd40

#65c0

            ; "de" will have the map pointer where the player should be rendered at.

#cd40

#65c0

            ; It should be == "hl" if not deferred.

#cd40

#65c0

1

5

    54

            ld d, h

#cd41

#65c1

1

5

    5d

            ld e, l

#cd42

#65c2

3

18

    cd 96 cd

            call Lcd96_find_near_in_front_map_element

#cd45

#65c5

1

12

    e5

            push hl

#cd46

#65c6

1

7

    2b

                dec hl

#cd47

#65c7

1

5

    25

                dec h

#cd48

#65c8

1

5

    25

                dec h

#cd49

#65c9

3

18

    cd 90 cd

                call Lcd90_find_near_in_front_map_element

#cd4c

#65cc

1

5

    24

                inc h

#cd4d

#65cd

1

5

    24

                inc h

#cd4e

#65ce

3

18

    cd 90 cd

                call Lcd90_find_near_in_front_map_element

#cd51

#65d1

1

5

    24

                inc h

#cd52

#65d2

1

5

    24

                inc h

#cd53

#65d3

1

5

    7c

                ld a, h

#cd54

#65d4

2

8

    fe fd

                cp #fd

#cd56

#65d6

2

13/8

    30 0b

                jr nc, Lcd63_out_of_map_bounds

#cd58

#65d8

3

18

    cd 90 cd

                call Lcd90_find_near_in_front_map_element

#cd5b

#65db

1

7

    23

                inc hl

#cd5c

#65dc

3

18

    cd 90 cd

                call Lcd90_find_near_in_front_map_element

#cd5f

#65df

1

7

    23

                inc hl

#cd60

#65e0

3

18

    cd 90 cd

                call Lcd90_find_near_in_front_map_element

#cd63

#65e3

    Lcd63_out_of_map_bounds:

#cd63

#65e3

1

11

    e1

            pop hl

#cd64

#65e4

1

5

    7a

            ld a, d

#cd65

#65e5

1

5

    bc

            cp h

#cd66

#65e6

2

13/8

    20 07

            jr nz, Lcd6f_defer_player_rendering

#cd68

#65e8

1

5

    7b

            ld a, e

#cd69

#65e9

1

5

    bd

            cp l

#cd6a

#65ea

2

13/8

    20 03

            jr nz, Lcd6f_defer_player_rendering

#cd6c

#65ec

1

11

    d1

        pop de

#cd6d

#65ed

2

13

    18 12

        jr Lcd81_render_player_push

#cd6f

#65ef

    Lcd6f_defer_player_rendering:

#cd6f

#65ef

1

5

    eb

            ex de, hl

#cd70

#65f0

2

17

    cb fe

            set 7, (hl)  ; mark the player as being in the deferred coordinates.

#cd72

#65f2

1

5

    eb

            ex de, hl

#cd73

#65f3

1

11

    d1

        pop de

#cd74

#65f4

4

22

    ed 53 11 fd

        ld (Lfd11_player_iso_coordinates_if_deferred), de

#cd78

#65f8

1

11

    c9

        ret

#cd79

#65f9

#cd79

#65f9

    Lcd79_player_rendering_was_deferred:

#cd79

#65f9

2

17

    cb be

        res 7, (hl)  ; remove the player mark from the deferred position

#cd7b

#65fb

1

12

    e5

        push hl

#cd7c

#65fc

1

12

    d5

        push de

#cd7d

#65fd

1

5

    50

            ld d, b

#cd7e

#65fe

1

5

    59

            ld e, c  ; set the correct isometric coordinates (before it was deferred).

#cd7f

#65ff

2

13

    18 02

            jr Lcd83_render_player

#cd81

#6601

#cd81

#6601

    Lcd81_render_player_push:

#cd81

#6601

1

12

    e5

        push hl

#cd82

#6602

1

12

    d5

        push de

#cd83

#6603

    Lcd83_render_player:

#cd83

#6603

3

14

    3a 10 fd

            ld a, (Lfd10_player_altitude)

#cd86

#6606

3

14

    32 3f cf

            ld (Lcf3f_selfmodifying_sprite_elevation), a

#cd89

#6609

1

5

    af

            xor a

#cd8a

#660a

3

18

    cd 2d cf

            call Lcf2d_draw_sprite_to_buffer

#cd8d

#660d

1

11

    d1

        pop de

#cd8e

#660e

1

11

    e1

        pop hl

#cd8f

#660f

1

11

    c9

        ret

#cd90

#6610

#cd90

#6610

#cd90

#6610

    ; --------------------------------

#cd90

#6610

    ; Sees if there is a map element that would be rendered on top of the object in "hl", and

#cd90

#6610

    ; returns its map pointer in de

#cd90

#6610

    ; Input:

#cd90

#6610

    ; - hl: map ptr to check

#cd90

#6610

    ; - de: map ptr to update if we find a "more in front" map element

#cd90

#6610

    Lcd90_find_near_in_front_map_element:

#cd90

#6610

2

14

    cb 76

        bit 6, (hl)

#cd92

#6612

1

12/6

    c8

        ret z

#cd93

#6613

3

18

    cd bf cd

        call Lcdbf_update_de_if_hl_more_in_front_internal

#cd96

#6616

    Lcd96_find_near_in_front_map_element:

#cd96

#6616

1

12

    e5

        push hl

#cd97

#6617

1

7

    2b

            dec hl  ; x -= 1

#cd98

#6618

1

5

    24

            inc h  ; y += 1

#cd99

#6619

1

5

    24

            inc h

#cd9a

#661a

1

5

    7c

            ld a, h

#cd9b

#661b

2

8

    fe fd

            cp #fd  ; check if pointer is outside of map bounds

#cd9d

#661d

2

13/8

    30 08

            jr nc, Lcda7_skip_first_row  ; out of bounds

#cd9f

#661f

3

18

    cd b8 cd

            call Lcdb8_update_de_if_hl_more_in_front

#cda2

#6622

1

7

    23

            inc hl  ; x += 1

#cda3

#6623

3

18

    cd b8 cd

            call Lcdb8_update_de_if_hl_more_in_front

#cda6

#6626

1

7

    2b

            dec hl  ; x -= 1

#cda7

#6627

    Lcda7_skip_first_row:

#cda7

#6627

1

5

    25

            dec h

#cda8

#6628

1

5

    25

            dec h  ; y -= 1

#cda9

#6629

3

18

    cd b8 cd

            call Lcdb8_update_de_if_hl_more_in_front

#cdac

#662c

1

7

    23

            inc hl  ; x += 1

#cdad

#662d

1

7

    23

            inc hl  ; x += 1

#cdae

#662e

1

5

    24

            inc h  ; y += 1

#cdaf

#662f

1

5

    24

            inc h

#cdb0

#6630

1

5

    7c

            ld a, h

#cdb1

#6631

2

8

    fe fd

            cp #fd  ; check if pointer is outside of map bounds

#cdb3

#6633

3

18/11

    dc b8 cd

            call c, Lcdb8_update_de_if_hl_more_in_front

#cdb6

#6636

1

11

    e1

        pop hl

#cdb7

#6637

1

11

    c9

        ret

#cdb8

#6638

#cdb8

#6638

#cdb8

#6638

    ; --------------------------------

#cdb8

#6638

    ; Checks if there is a map element in "hl" that is "in front" (rendered lower in the screen) of the

#cdb8

#6638

    ; position pointed to by "de", and if so, overwrites "de" with "hl".

#cdb8

#6638

    ; Input:

#cdb8

#6638

    ; - hl: map ptr to check

#cdb8

#6638

    ; - de: map ptr to update if we find a "more in front" map element

#cdb8

#6638

    Lcdb8_update_de_if_hl_more_in_front:

#cdb8

#6638

2

14

    cb 6e

        bit 5, (hl)

#cdba

#663a

1

12/6

    c0

        ret nz  ; return if this is not the bottom-left corner of the a map object

#cdbb

#663b

1

8

    7e

        ld a, (hl)

#cdbc

#663c

2

8

    e6 1f

        and #1f

#cdbe

#663e

1

12/6

    c8

        ret z  ; return if there is nothing in this map position

#cdbf

#663f

        ; If we are here is that we are in a map position with the bottom-left corner of a map element.

#cdbf

#663f

    Lcdbf_update_de_if_hl_more_in_front_internal:

#cdbf

#663f

1

5

    7b

        ld a, e

#cdc0

#6640

1

5

    95

        sub l

#cdc1

#6641

1

5

    4f

        ld c, a  ; c = e - l  (difference in x, ignoring highest bit)

#cdc2

#6642

1

5

    7a

        ld a, d

#cdc3

#6643

2

8

    d6 dd

        sub #dd

#cdc5

#6645

2

10

    cb 3f

        srl a

#cdc7

#6647

1

5

    47

        ld b, a  ; b = (d - #dd) / 2

#cdc8

#6648

1

5

    7c

        ld a, h

#cdc9

#6649

2

8

    d6 dd

        sub #dd

#cdcb

#664b

2

10

    cb 3f

        srl a  ; a = (h - #dd) / 2

#cdcd

#664d

1

5

    90

        sub b  ; a = ((h - #dd) / 2) - ((d - #dd) / 2)  (difference in y)

#cdce

#664e

1

5

    81

        add a, c  ; "a" has (hl.y - de.y) + (de.x - hl.x)

#cdcf

#664f

1

12/6

    f8

        ret m  ; return if whatever is in "de" is rendered "lower on the screen" when projected,

#cdd0

#6650

2

13/8

    20 03

        jr nz, Lcdd5

#cdd2

#6652

1

5

    79

        ld a, c  ; c still contains e - l (difference in x)

#cdd3

#6653

1

5

    b7

        or a

#cdd4

#6654

1

12/6

    f0

        ret p  ; return if whatever is in de has a higher x coordinate.

#cdd5

#6655

    Lcdd5:

#cdd5

#6655

1

5

    54

        ld d, h

#cdd6

#6656

1

5

    5d

        ld e, l

#cdd7

#6657

1

11

    c9

        ret

#cdd8

#6658

#cdd8

#6658

#cdd8

#6658

    ; --------------------------------

#cdd8

#6658

    ; Finds if there is a robot with the same map pointer as hl, and returns it in "iy".

#cdd8

#6658

    ; Input:

#cdd8

#6658

    ; - hl: map ptr

#cdd8

#6658

    ; Output:

#cdd8

#6658

    ; - iy: robot ptr

#cdd8

#6658

    ; - z: robot found

#cdd8

#6658

    ; - nz: no robot found

#cdd8

#6658

    Lcdd8_get_robot_at_ptr:

#cdd8

#6658

4

16

    fd 21 00 da

        ld iy, Lda00_player1_robots

#cddc

#665c

2

8

    06 30

        ld b, MAX_ROBOTS_PER_PLAYER * 2

#cdde

#665e

    Lcdde_get_robot_below_player_loop:

#cdde

#665e

3

21

    fd 7e 00

        ld a, (iy + ROBOT_STRUCT_MAP_PTR)

#cde1

#6661

1

5

    bd

        cp l

#cde2

#6662

2

13/8

    20 05

        jr nz, Lcde9_next_robot

#cde4

#6664

3

21

    fd 7e 01

        ld a, (iy + ROBOT_STRUCT_MAP_PTR + 1)

#cde7

#6667

1

5

    bc

        cp h

#cde8

#6668

1

12/6

    c8

        ret z

#cde9

#6669

    Lcde9_next_robot:

#cde9

#6669

1

12

    d5

        push de

#cdea

#666a

3

11

    11 10 00

            ld de, ROBOT_STRUCT_SIZE

#cded

#666d

2

17

    fd 19

            add iy, de

#cdef

#666f

1

11

    d1

        pop de

#cdf0

#6670

2

14/9

    10 ec

        djnz Lcdde_get_robot_below_player_loop

#cdf2

#6672

2

8

    f6 01

        or 1

#cdf4

#6674

1

11

    c9

        ret

#cdf5

#6675

#cdf5

#6675

#cdf5

#6675

    ; --------------------------------

#cdf5

#6675

    ; Find decoration at map pointer hl

#cdf5

#6675

    ; Input:

#cdf5

#6675

    ; - hl: map pointer to find a decoration for.

#cdf5

#6675

    ; Returns:

#cdf5

#6675

    ; - iy: ptr to a decoration that has "hl" as the map pointer (if found)

#cdf5

#6675

    ; - z: decoration found.

#cdf5

#6675

    ; - nz: decoration not found.

#cdf5

#6675

    Lcdf5_find_building_decoration_with_ptr:

#cdf5

#6675

4

16

    fd 21 01 ff

        ld iy, Lff01_building_decorations

#cdf9

#6679

2

8

    06 38

        ld b, 56

#cdfb

#667b

    Lcdfb_loop:

#cdfb

#667b

3

21

    fd 7e 00

        ld a, (iy + BULLET_STRUCT_MAP_PTR)

#cdfe

#667e

1

5

    bd

        cp l

#cdff

#667f

2

13/8

    20 05

        jr nz, Lce06_skip

#ce01

#6681

3

21

    fd 7e 01

        ld a, (iy + BULLET_STRUCT_MAP_PTR + 1)

#ce04

#6684

1

5

    bc

        cp h

#ce05

#6685

1

12/6

    c8

        ret z

#ce06

#6686

    Lce06_skip:

#ce06

#6686

1

12

    d5

        push de

#ce07

#6687

3

11

    11 03 00

            ld de, 3

#ce0a

#668a

2

17

    fd 19

            add iy, de

#ce0c

#668c

1

11

    d1

        pop de

#ce0d

#668d

2

14/9

    10 ec

        djnz Lcdfb_loop

#ce0f

#668f

2

8

    f6 01

        or 1

#ce11

#6691

1

11

    c9

        ret

#ce12

#6692

#ce12

#6692

#ce12

#6692

    ; --------------------------------

#ce12

#6692

    ; See if there is an object (robot, decoration, bullet) with map ptr equal to "hl" and draws it.

#ce12

#6692

    ; Input:

#ce12

#6692

    ; - hl: map ptr

#ce12

#6692

    ; - de: isometric coordinates

#ce12

#6692

    Lce12_draw_object_to_map:

#ce12

#6692

3

18

    cd d8 cd

        call Lcdd8_get_robot_at_ptr

#ce15

#6695

2

13/8

    28 51

        jr z, Lce68_draw_robot_or_bullet  ; if there is a robot, draw it

#ce17

#6697

3

18

    cd f5 cd

        call Lcdf5_find_building_decoration_with_ptr

#ce1a

#669a

2

13/8

    28 1c

        jr z, Lce38_draw_decoration  ; if there is a decoration, draw it

#ce1c

#669c

4

16

    fd 21 d3 d7

        ld iy, Ld7d3_bullets

#ce20

#66a0

2

8

    06 05

        ld b, MAX_BULLETS

#ce22

#66a2

    Lce22_loop_bullet:

#ce22

#66a2

3

21

    fd 7e 00

        ld a, (iy + BULLET_STRUCT_MAP_PTR)

#ce25

#66a5

1

5

    bd

        cp l

#ce26

#66a6

2

13/8

    20 06

        jr nz, Lce2e_next_bullet

#ce28

#66a8

3

21

    fd 7e 01

        ld a, (iy + BULLET_STRUCT_MAP_PTR + 1)

#ce2b

#66ab

1

5

    bc

        cp h

#ce2c

#66ac

2

13/8

    28 3a

        jr z, Lce68_draw_robot_or_bullet  ; if there is a bullet, draw it

#ce2e

#66ae

    Lce2e_next_bullet:

#ce2e

#66ae

1

12

    d5

        push de

#ce2f

#66af

3

11

    11 09 00

            ld de, BULLET_STRUCT_SIZE

#ce32

#66b2

2

17

    fd 19

            add iy, de

#ce34

#66b4

1

11

    d1

        pop de

#ce35

#66b5

2

14/9

    10 eb

        djnz Lce22_loop_bullet

#ce37

#66b7

1

11

    c9

        ret

#ce38

#66b8

#ce38

#66b8

#ce38

#66b8

    ; --------------------------------

#ce38

#66b8

    ; Draws a decoration to the map (a flag, the "H" in a warbase, pieces on top of factories.)

#ce38

#66b8

    ; Input:

#ce38

#66b8

    ; - iy: decoration ptr

#ce38

#66b8

    ; - de: isometric coordinates

#ce38

#66b8

    Lce38_draw_decoration:

#ce38

#66b8

1

12

    e5

        push hl

#ce39

#66b9

1

12

    d5

        push de

#ce3a

#66ba

3

21

    fd 7e 02

            ld a, (iy + BUILDING_DECORATION_STRUCT_TYPE)

#ce3d

#66bd

1

5

    4f

            ld c, a

#ce3e

#66be

3

11

    21 5f ce

            ld hl, Lce5f_decoration_drawing_elevations

#ce41

#66c1

3

18

    cd 51 d3

            call Ld351_add_hl_a

#ce44

#66c4

1

8

    7e

            ld a, (hl)

#ce45

#66c5

3

14

    32 3f cf

            ld (Lcf3f_selfmodifying_sprite_elevation), a

#ce48

#66c8

1

5

    79

            ld a, c

#ce49

#66c9

3

11

    21 56 ce

            ld hl, Lce56_decoration_sprite_indexes

#ce4c

#66cc

3

18

    cd 51 d3

            call Ld351_add_hl_a

#ce4f

#66cf

1

8

    7e

            ld a, (hl)

#ce50

#66d0

3

18

    cd 2d cf

            call Lcf2d_draw_sprite_to_buffer

#ce53

#66d3

1

11

    d1

        pop de

#ce54

#66d4

1

11

    e1

        pop hl

#ce55

#66d5

1

11

    c9

        ret

#ce56

#66d6

#ce56

#66d6

    Lce56_decoration_sprite_indexes:

#ce56

#66d6

9

        db #2c, #28, #25, #23, #20, #1d, #17, #2a, #2b

#ce5f

#66df

    Lce5f_decoration_drawing_elevations:

#ce5f

#66df

9

        db #13, #0f, #0f, #0f, #0f, #0f, #0f, #1a, #1a

#ce68

#66e8

#ce68

#66e8

#ce68

#66e8

    ; --------------------------------

#ce68

#66e8

    ; Draws a bullet to the map.

#ce68

#66e8

    ; Input:

#ce68

#66e8

    ; - iy: bullet/robot struct ptr.

#ce68

#66e8

    ; - hl: map ptr.

#ce68

#66e8

    ; - d, e: isometric coordinates.

#ce68

#66e8

    Lce68_draw_robot_or_bullet:

#ce68

#66e8

1

12

    d5

        push de

#ce69

#66e9

1

5

    54

            ld d, h

#ce6a

#66ea

1

5

    5d

            ld e, l

#ce6b

#66eb

3

18

    cd 96 cd

            call Lcd96_find_near_in_front_map_element

#ce6e

#66ee

            ; if "de" is different from "hl", update the ptr of the bullet/robot instead of drawing it:

#ce6e

#66ee

            ; This is because it could be that the object in "de" would overwrite the bottom of the

#ce6e

#66ee

            ; object in "hl". So, we are just "deferring" the rendering.

#ce6e

#66ee

1

5

    7a

            ld a, d

#ce6f

#66ef

1

5

    bc

            cp h

#ce70

#66f0

2

13/8

    20 04

            jr nz, Lce76_update_robot_bullet_ptr  ; defer rendering

#ce72

#66f2

1

5

    7b

            ld a, e

#ce73

#66f3

1

5

    bd

            cp l

#ce74

#66f4

2

13/8

    28 0c

            jr z, Lce82_draw_robot_or_bullet_continue  ; if we only differ in "x" form the potential

#ce76

#66f6

                                                       ; occluder, continue

#ce76

#66f6

    Lce76_update_robot_bullet_ptr:

#ce76

#66f6

            ; Defer rendering to later, after we have drawn the map element in "de":

#ce76

#66f6

1

5

    eb

            ex de, hl

#ce77

#66f7

2

17

    cb f6

                set 6, (hl)

#ce79

#66f9

3

21

    fd 75 00

                ld (iy + BULLET_STRUCT_MAP_PTR), l

#ce7c

#66fc

3

21

    fd 74 01

                ld (iy + BULLET_STRUCT_MAP_PTR + 1), h

#ce7f

#66ff

1

5

    eb

            ex de, hl

#ce80

#6700

1

11

    d1

        pop de

#ce81

#6701

1

11

    c9

        ret

#ce82

#6702

#ce82

#6702

    Lce82_draw_robot_or_bullet_continue:

#ce82

#6702

1

11

    d1

        pop de  ; pop "de", which was pushed when we jumped here (isometric coordinates)

#ce83

#6703

1

12

    d5

        push de

#ce84

#6704

1

5

    eb

            ex de, hl  ; de = original map ptr.

#ce85

#6705

3

21

    fd 6e 02

            ld l, (iy + ROBOT_STRUCT_X)

#ce88

#6708

3

21

    fd 66 03

            ld h, (iy + ROBOT_STRUCT_X + 1)

#ce8b

#670b

3

21

    fd 7e 04

            ld a, (iy + ROBOT_STRUCT_Y)

#ce8e

#670e

3

18

    cd a6 cc

            call Lcca6_compute_map_ptr  ; recompute map ptr in "hl" from the x, y coordinates in "hl",

#ce91

#6711

                                        ; "a".

#ce91

#6711

            ; If the "Lcd96_find_near_in_front_map_element" call above found an object that will be

#ce91

#6711

            ; drawn later and would occlude this one, do not draw yet:

#ce91

#6711

1

5

    7a

            ld a, d

#ce92

#6712

1

5

    bc

            cp h

#ce93

#6713

2

13/8

    20 07

            jr nz, Lce9c_object_was_deferred  ; This means that the object was deferred for rendering

#ce95

#6715

                                              ; earlier, so, we draw it now.

#ce95

#6715

1

5

    7b

            ld a, e

#ce96

#6716

1

5

    bd

            cp l

#ce97

#6717

2

13/8

    20 03

            jr nz, Lce9c_object_was_deferred  ; This means that the object was deferred for rendering

#ce99

#6719

                                              ; earlier, so, we draw it now.

#ce99

#6719

1

11

    d1

        pop de

#ce9a

#671a

2

13

    18 27

        jr Lcec3_draw_robot_or_bullet_internal

#ce9c

#671c

    Lce9c_object_was_deferred:

#ce9c

#671c

            ; Reestablish the pointer of the object to its original value:

#ce9c

#671c

3

21

    fd 75 00

            ld (iy + ROBOT_STRUCT_MAP_PTR), l

#ce9f

#671f

3

21

    fd 74 01

            ld (iy + ROBOT_STRUCT_MAP_PTR + 1), h

#cea2

#6722

1

5

    44

            ld b, h

#cea3

#6723

1

5

    4d

            ld c, l

#cea4

#6724

1

5

    eb

            ex de, hl

#cea5

#6725

1

11

    d1

        pop de

#cea6

#6726

1

12

    d5

        push de

#cea7

#6727

1

12

    e5

        push hl

#cea8

#6728

2

17

    cb b6

            res 6, (hl)  ; remove the object from its deferred position

#ceaa

#672a

1

7

    2b

            dec hl

#ceab

#672b

1

5

    1d

            dec e

#ceac

#672c

            ; Adjust the isometric coordinates to account for the fact that the object was moved to

#ceac

#672c

            ; defer its rendering.

#ceac

#672c

    Lceac_loop_x:

#ceac

#672c

1

5

    79

            ld a, c

#cead

#672d

1

5

    bd

            cp l

#ceae

#672e

2

13/8

    28 04

            jr z, Lceb4_loop_y

#ceb0

#6730

1

7

    23

            inc hl

#ceb1

#6731

1

5

    1c

            inc e

#ceb2

#6732

2

13

    18 f8

            jr Lceac_loop_x

#ceb4

#6734

    Lceb4_loop_y:

#ceb4

#6734

1

5

    78

            ld a, b

#ceb5

#6735

1

5

    bc

            cp h

#ceb6

#6736

2

13/8

    28 05

            jr z, Lcebd_loop_exit

#ceb8

#6738

1

5

    25

            dec h

#ceb9

#6739

1

5

    25

            dec h

#ceba

#673a

1

5

    15

            dec d

#cebb

#673b

2

13

    18 f7

            jr Lceb4_loop_y

#cebd

#673d

    Lcebd_loop_exit:

#cebd

#673d

3

18

    cd c3 ce

            call Lcec3_draw_robot_or_bullet_internal

#cec0

#6740

1

11

    e1

        pop hl

#cec1

#6741

1

11

    d1

        pop de

#cec2

#6742

1

11

    c9

        ret

#cec3

#6743

#cec3

#6743

#cec3

#6743

    ; --------------------------------

#cec3

#6743

    ; Draws the sprites corresponding to a bullet or robot to the double buffer.

#cec3

#6743

    ; Input:

#cec3

#6743

    ; - iy: robot/bullet ptr.

#cec3

#6743

    Lcec3_draw_robot_or_bullet_internal:

#cec3

#6743

2

17

    fd e5

        push iy

#cec5

#6745

1

11

    c1

        pop bc

#cec6

#6746

1

5

    78

        ld a, b  ; Potential optimization: push/pop not needed, just "la a,iyh"

#cec7

#6747

2

8

    fe d8

        cp #d8  ; bullets have pointers < #d800, if its bigger, it's a robot.

#cec9

#6749

3

11

    d2 e8 ce

        jp nc, Lcee8_draw_robot_to_buffer

#cecc

#674c

        ; Draw the bullet

#cecc

#674c

1

12

    e5

        push hl

#cecd

#674d

1

12

    d5

        push de

#cece

#674e

3

21

    fd 4e 07

            ld c, (iy + BULLET_STRUCT_TYPE)

#ced1

#6751

3

21

    fd 7e 05

            ld a, (iy + BULLET_STRUCT_DIRECTION)

#ced4

#6754

            ; get the sprite # of the bullet:

#ced4

#6754

2

8

    fe 03

            cp 3

#ced6

#6756

1

5

    3f

            ccf

#ced7

#6757

2

10

    cb 11

            rl c

#ced9

#6759

3

21

    fd 7e 08

            ld a, (iy + BULLET_STRUCT_ALTITUDE)

#cedc

#675c

3

14

    32 3f cf

            ld (Lcf3f_selfmodifying_sprite_elevation), a

#cedf

#675f

            ; get the sprite # of the bullet (continued):

#cedf

#675f

2

8

    3e 2b

            ld a, 43

#cee1

#6761

1

5

    81

            add a, c

#cee2

#6762

3

18

    cd 2d cf

            call Lcf2d_draw_sprite_to_buffer

#cee5

#6765

1

11

    d1

        pop de

#cee6

#6766

1

11

    e1

        pop hl

#cee7

#6767

1

11

    c9

        ret

#cee8

#6768

#cee8

#6768

#cee8

#6768

    ; --------------------------------

#cee8

#6768

    ; Input:

#cee8

#6768

    ; - de: isometric coordinates

#cee8

#6768

    ; - iy: pointer to the robot struct

#cee8

#6768

    Lcee8_draw_robot_to_buffer:

#cee8

#6768

1

12

    e5

        push hl

#cee9

#6769

3

21

    fd 4e 07

            ld c, (iy + ROBOT_STRUCT_PIECES)  ; which pieces are selected for the robot (1 bit per

#ceec

#676c

                                              ; piece).

#ceec

#676c

2

8

    06 08

            ld b, 8  ; up to 8 different pieces

#ceee

#676e

3

21

    fd 7e 0d

            ld a, (iy + ROBOT_STRUCT_ALTITUDE)

#cef1

#6771

3

14

    32 3f cf

            ld (Lcf3f_selfmodifying_sprite_elevation), a

#cef4

#6774

    Lcef4_piece_loop:

#cef4

#6774

2

10

    cb 19

            rr c

#cef6

#6776

3

18/11

    dc fd ce

            call c, Lcefd_draw_robot_piece_to_buffer  ; if the piece is selected, draw it.

#cef9

#6779

2

14/9

    10 f9

            djnz Lcef4_piece_loop

#cefb

#677b

1

11

    e1

        pop hl

#cefc

#677c

1

11

    c9

        ret

#cefd

#677d

#cefd

#677d

#cefd

#677d

    ; --------------------------------

#cefd

#677d

    ; Input:

#cefd

#677d

    ; - b: 8 - piece to draw

#cefd

#677d

    ; - de: isometric coordinates

#cefd

#677d

    ; - iy: robot ptr.

#cefd

#677d

    Lcefd_draw_robot_piece_to_buffer:

#cefd

#677d

1

12

    c5

        push bc

#cefe

#677e

1

12

    d5

        push de

#ceff

#677f

2

8

    3e 08

            ld a, 8

#cf01

#6781

1

5

    90

            sub b  ; a = piece to draw (0 = bipod, 1 = tracks, etc.)

#cf02

#6782

1

12

    f5

            push af

#cf03

#6783

3

21

    fd 4e 08

                ld c, (iy + ROBOT_STRUCT_DIRECTION)  ; one-hot representation of the robot direction

#cf06

#6786

2

8

    06 ff

                ld b, 255  ; b will contain the direction (south-east, south-west, etc.)

#cf08

#6788

    Lcf08_direction_loop:

#cf08

#6788

1

5

    04

                inc b

#cf09

#6789

2

10

    cb 19

                rr c

#cf0b

#678b

2

13/8

    30 fb

                jr nc, Lcf08_direction_loop

#cf0d

#678d

1

5

    87

                add a, a

#cf0e

#678e

1

5

    87

                add a, a

#cf0f

#678f

1

5

    80

                add a, b  ; a now contains the offset in the graphic indices table of the piece graphic

#cf10

#6790

                          ; to draw.

#cf10

#6790

3

11

    21 c8 d6

                ld hl, Ld6c8_piece_direction_graphic_indices

#cf13

#6793

3

18

    cd 51 d3

                call Ld351_add_hl_a

#cf16

#6796

1

8

    7e

                ld a, (hl)  ; a now contains the index of the piece graphic to draw in the graphics

#cf17

#6797

                            ; table.

#cf17

#6797

2

8

    c6 16

                add a, 22  ; + 22, since this will be later multiplied by 2, and is to skip the first

#cf19

#6799

                           ; 44 graphics in the "Ld6e8_additional_isometric_graphic_pointers" table.

#cf19

#6799

3

18

    cd 2d cf

                call Lcf2d_draw_sprite_to_buffer

#cf1c

#679c

1

11

    f1

            pop af

#cf1d

#679d

1

11

    d1

        pop de

#cf1e

#679e

1

11

    c1

        pop bc

#cf1f

#679f

3

11

    21 b4 d7

        ld hl, Ld7b4_piece_heights

#cf22

#67a2

3

18

    cd 51 d3

        call Ld351_add_hl_a  ; get piece height

#cf25

#67a5

3

14

    3a 3f cf

        ld a, (Lcf3f_selfmodifying_sprite_elevation)

#cf28

#67a8

1

8

    86

        add a, (hl)

#cf29

#67a9

3

14

    32 3f cf

        ld (Lcf3f_selfmodifying_sprite_elevation), a

#cf2c

#67ac

1

11

    c9

        ret

#cf2d

#67ad

#cf2d

#67ad

#cf2d

#67ad

    ; --------------------------------

#cf2d

#67ad

    ; input:

#cf2d

#67ad

    ; - a: index of the graphic to draw from Ld6e8_additional_isometric_graphic_pointers (divided by 2)

#cf2d

#67ad

    ; - d, e: isometric coordinates.

#cf2d

#67ad

    Lcf2d_draw_sprite_to_buffer:

#cf2d

#67ad

1

5

    4f

        ld c, a  ; we save the graphic to draw in c

#cf2e

#67ae

        ; calculate the screen x coordinate:

#cf2e

#67ae

2

10

    cb 03

        rlc e

#cf30

#67b0

1

5

    7b

        ld a, e

#cf31

#67b1

1

5

    82

        add a, d

#cf32

#67b2

2

8

    d6 18

        sub 24

#cf34

#67b4

1

5

    6f

        ld l, a  ; l (x coordinate in nibbles) = e*2 + d - 24

#cf35

#67b5

        ; calculate the screen y coordinate:

#cf35

#67b5

2

10

    cb 03

        rlc e

#cf37

#67b7

1

5

    7a

        ld a, d

#cf38

#67b8

1

5

    87

        add a, a

#cf39

#67b9

1

5

    87

        add a, a

#cf3a

#67ba

1

5

    87

        add a, a

#cf3b

#67bb

2

8

    c6 64

        add a, 100

#cf3d

#67bd

1

5

    93

        sub e

#cf3e

#67be

    Lcf3f_selfmodifying_sprite_elevation: equ $ + 1

#cf3e

#67be

2

8

    d6 00

        sub 0  ; a = d*8+100 - e*4 - (Lcf3f_selfmodifying_sprite_elevation)  ; mdl:self-modifying

#cf40

#67c0

1

5

    67

        ld h, a  ; h: y coordinate to draw to in pixels (starting from the bottom of the sprite)

#cf41

#67c1

1

5

    79

        ld a, c  ; restore the graphic to draw

#cf42

#67c2

2

8

    e6 3f

        and #3f

#cf44

#67c4

        ; here l = x coordinate in nibbles

#cf44

#67c4

2

10

    cb 2d

        sra l  ; we push the least significant bit to the carry (now l is x coordinate in bytes)

#cf46

#67c6

        ; Here we have the coordinates where to draw:

#cf46

#67c6

        ; - l: x coordinate in bytes

#cf46

#67c6

        ; - h: y coordinate in pixels

#cf46

#67c6

1

5

    8f

        adc a, a  ; The carry is now added to the index, since each odd sprite is already

#cf47

#67c7

                  ; pre-calculated with a 4 pixel offset in the x axis.

#cf47

#67c7

1

12

    e5

        push hl

#cf48

#67c8

3

11

    21 e8 d6

            ld hl, Ld6e8_additional_isometric_graphic_pointers

#cf4b

#67cb

3

18

    cd 48 d3

            call Ld348_get_ptr_from_table

#cf4e

#67ce

1

8

    4e

            ld c, (hl)  ; height in pixels

#cf4f

#67cf

1

7

    23

            inc hl

#cf50

#67d0

1

8

    46

            ld b, (hl)  ; width in bytes

#cf51

#67d1

1

7

    23

            inc hl

#cf52

#67d2

1

5

    eb

            ex de, hl  ; de: pointer to the actual graphic data

#cf53

#67d3

1

11

    e1

        pop hl

#cf54

#67d4

1

5

    af

        xor a

#cf55

#67d5

3

14

    32 af cf

        ld (Lcfaf_selfmodifying_left_pixel_skip), a  ; do not skip pixels from the left by default

#cf58

#67d8

1

5

    7d

        ld a, l

#cf59

#67d9

2

8

    fe 14

        cp 20

#cf5b

#67db

1

12/6

    f0

        ret p  ; if we are drawing beyond the buffer right edge, we are done

#cf5c

#67dc

1

5

    7c

        ld a, h

#cf5d

#67dd

2

8

    fe a0

        cp 160

#cf5f

#67df

2

13/8

    38 16

        jr c, Lcf77_clip_sprite_left

#cf61

#67e1

2

8

    fe e2

        cp 226

#cf63

#67e3

1

12/6

    d0

        ret nc  ; if we are drawing outside of the draw-able area from top/bottom, we are done

#cf64

#67e4

2

8

    d6 9f

        sub 159

#cf66

#67e6

1

5

    91

        sub c  ; if we are drawing starting outside the buffer area, and the sprite is not tall enough

#cf67

#67e7

               ; to actually overlap with the viewable area, we are done.

#cf67

#67e7

1

12/6

    f0

        ret p

#cf68

#67e8

2

10

    ed 44

        neg

#cf6a

#67ea

1

5

    4f

        ld c, a  ; update the height of the sprite to draw

#cf6b

#67eb

    Lcf6b_skip_line_outer_loop:

#cf6b

#67eb

        ; skip all the lines that would be drawn outside of the viewable area:

#cf6b

#67eb

1

12

    c5

        push bc

#cf6c

#67ec

    Lcf6c_skip_line_inner_loop:

#cf6c

#67ec

1

7

    13

            inc de

#cf6d

#67ed

1

7

    13

            inc de

#cf6e

#67ee

2

14/9

    10 fc

            djnz Lcf6c_skip_line_inner_loop

#cf70

#67f0

1

11

    c1

        pop bc

#cf71

#67f1

1

5

    25

        dec h

#cf72

#67f2

1

5

    7c

        ld a, h

#cf73

#67f3

2

8

    fe 9f

        cp 159

#cf75

#67f5

2

13/8

    20 f4

        jr nz, Lcf6b_skip_line_outer_loop

#cf77

#67f7

    Lcf77_clip_sprite_left:

#cf77

#67f7

1

5

    7d

        ld a, l  ; start x coordinate

#cf78

#67f8

1

5

    b7

        or a

#cf79

#67f9

3

11

    f2 85 cf

        jp p, Lcf85_clip_sprite_right

#cf7c

#67fc

2

10

    ed 44

        neg  ; if sprite overflows from the left, clip sprite from the left:

#cf7e

#67fe

3

14

    32 af cf

        ld (Lcfaf_selfmodifying_left_pixel_skip), a

#cf81

#6801

2

8

    2e 00

        ld l, 0  ; set drawing coordinate to 0

#cf83

#6803

1

5

    b8

        cp b  ; if we are skipping the whole sprite, we are done

#cf84

#6804

1

12/6

    d0

        ret nc

#cf85

#6805

    Lcf85_clip_sprite_right:

#cf85

#6805

        ; See if the sprite would overflow the buffer from the right, and clip sprite from the right if

#cf85

#6805

        ; necessary:

#cf85

#6805

1

5

    7d

        ld a, l  ; start x coordinate

#cf86

#6806

1

5

    80

        add a, b  ; sprite width

#cf87

#6807

2

8

    fe 15

        cp 21

#cf89

#6809

2

13/8

    38 0a

        jr c, Lcf95_calculate_buffer_pointer_to_draw_to

#cf8b

#680b

2

8

    d6 14

        sub 20  ; a now has the number of bytes we want to skip from the left of the sprite

#cf8d

#680d

3

14

    32 af cf

        ld (Lcfaf_selfmodifying_left_pixel_skip), a

#cf90

#6810

        ; What this loop does is to move the pointer to draw to the left, and set the number of pixels

#cf90

#6810

        ; to skip from the left, so that, effectively, we are skipping pixels from the right:

#cf90

#6810

    Lcf90_skip_right_pixels_initially_loop:

#cf90

#6810

1

7

    1b

        dec de

#cf91

#6811

1

7

    1b

        dec de

#cf92

#6812

1

5

    3d

        dec a

#cf93

#6813

2

13/8

    20 fb

        jr nz, Lcf90_skip_right_pixels_initially_loop

#cf95

#6815

    Lcf95_calculate_buffer_pointer_to_draw_to:

#cf95

#6815

1

12

    d5

        push de

#cf96

#6816

            ; Calculate the pointer to where we want to draw the sprite in the buffer:

#cf96

#6816

            ; - l: x coordinate in bytes

#cf96

#6816

            ; - h: y coordinate in pixels

#cf96

#6816

1

5

    7d

            ld a, l

#cf97

#6817

1

12

    f5

            push af

#cf98

#6818

1

5

    6c

                ld l, h

#cf99

#6819

2

8

    26 00

                ld h, 0

#cf9b

#681b

1

12

    29

                add hl, hl

#cf9c

#681c

1

12

    29

                add hl, hl  ; hl = h*4

#cf9d

#681d

1

5

    54

                ld d, h

#cf9e

#681e

1

5

    5d

                ld e, l

#cf9f

#681f

1

12

    29

                add hl, hl

#cfa0

#6820

1

12

    29

                add hl, hl

#cfa1

#6821

1

12

    19

                add hl, de

#cfa2

#6822

1

11

    f1

            pop af

#cfa3

#6823

3

18

    cd 51 d3

            call Ld351_add_hl_a  ; hl = h*20 + l

#cfa6

#6826

3

11

    11 00 5b

            ld de, L5b00_double_buffer

#cfa9

#6829

1

12

    19

            add hl, de  ; hl = buffer pointer where to start drawing

#cfaa

#682a

1

11

    d1

        pop de

#cfab

#682b

1

5

    eb

        ex de, hl

#cfac

#682c

        ; Draws a sprite from "hl" to "de" ("de" points to a memory buffer with 20 bytes per row of

#cfac

#682c

        ; pixels):

#cfac

#682c

        ; - b: sprite width in bytes (b*8 pixels)

#cfac

#682c

        ; - c: sprite height in pixels

#cfac

#682c

    Lcfac_draw_loop_y:

#cfac

#682c

1

12

    c5

        push bc

#cfad

#682d

1

12

    d5

        push de

#cfae

#682e

    Lcfaf_selfmodifying_left_pixel_skip: equ $ + 1

#cfae

#682e

2

8

    3e 00

            ld a, 0  ; mdl:self-modifying

#cfb0

#6830

1

5

    b7

            or a  ; if we are no skipping pixels from the left, skip the loop

#cfb1

#6831

3

11

    ca bb cf

            jp z, Lcfbb_draw_loop_x

#cfb4

#6834

            ; Skips "a*8" from the left of the sprite to draw:

#cfb4

#6834

    Lcfb4_skip_left_pixels_loop:

#cfb4

#6834

1

7

    23

            inc hl

#cfb5

#6835

1

7

    23

            inc hl

#cfb6

#6836

1

5

    05

            dec b

#cfb7

#6837

1

5

    3d

            dec a

#cfb8

#6838

3

11

    c2 b4 cf

            jp nz, Lcfb4_skip_left_pixels_loop

#cfbb

#683b

            ; Writes a row of "b*8" pixels from hl to de:

#cfbb

#683b

    Lcfbb_draw_loop_x:

#cfbb

#683b

1

8

    1a

            ld a, (de)  ; read pixel from currently in the memory buffer

#cfbc

#683c

1

8

    a6

            and (hl)  ; applies and mask

#cfbd

#683d

1

7

    23

            inc hl

#cfbe

#683e

1

8

    b6

            or (hl)  ; applies or mask

#cfbf

#683f

1

8

    12

            ld (de), a  ; write pixel to the screen again

#cfc0

#6840

1

7

    23

            inc hl

#cfc1

#6841

1

7

    13

            inc de

#cfc2

#6842

2

14/9

    10 f7

            djnz Lcfbb_draw_loop_x

#cfc4

#6844

1

11

    d1

        pop de

#cfc5

#6845

1

11

    c1

        pop bc

#cfc6

#6846

        ; move to the previous row in the buffer (20 bytes per row, as that's the width of the in-game

#cfc6

#6846

        ; area)

#cfc6

#6846

2

8

    3e ec

        ld a, -20

#cfc8

#6848

1

5

    83

        add a, e

#cfc9

#6849

1

5

    5f

        ld e, a  ; e -= 20

#cfca

#684a

3

11

    da d2 cf

        jp c, Lcfd2_no_msb_update  ; if we don't need to update the most significant byte of the buffer

#cfcd

#684d

                                   ; address, just skip

#cfcd

#684d

1

5

    15

        dec d

#cfce

#684e

1

5

    7a

        ld a, d

#cfcf

#684f

2

8

    fe 5a

        cp #5a  ; we are drawing in a buffer that starts in #5b00, so, if the most-significant byte is

#cfd1

#6851

                ; #5a, it means we are out of the buffer area, and we should stop drawing.

#cfd1

#6851

1

12/6

    c8

        ret z

#cfd2

#6852

    Lcfd2_no_msb_update:

#cfd2

#6852

1

5

    0d

        dec c

#cfd3

#6853

3

11

    c2 ac cf

        jp nz, Lcfac_draw_loop_y

#cfd6

#6856

1

11

    c9

        ret

#cfd7

#6857

#cfd7

#6857

#cfd7

#6857

    ; --------------------------------

#cfd7

#6857

    ; Clears the screen buffer in #5b00, and draws the basic map frame (thw two diagonal cut-out

#cfd7

#6857

    ; patterns that can be seen in the game, to give the appearance of 3d).

#cfd7

#6857

    Lcfd7_draw_blank_map_in_buffer:

#cfd7

#6857

3

18

    cd fe cf

        call Lcffe_clear_5b00_buffer

#cfda

#685a

3

18

    cd 26 d0

        call Ld026_draw_top_left_diagonal_map_edge

#cfdd

#685d

3

11

    21 a8 d6

        ld hl, Ld6a8_diagonal_pattern1

#cfe0

#6860

2

8

    06 06

        ld b, 6

#cfe2

#6862

3

11

    11 0a 5b

        ld de, L5b00_double_buffer + 10

#cfe5

#6865

3

18

    cd 57 d0

        call Ld057_draw_diagonal_line  ; draws the top-left edge of the map in screen

#cfe8

#6868

3

11

    21 a8 d6

        ld hl, Ld6a8_diagonal_pattern1

#cfeb

#686b

2

8

    06 03

        ld b, 3

#cfed

#686d

3

11

    11 b2 65

        ld de, L5b00_double_buffer + 136 * 20 + 18

#cff0

#6870

3

18

    cd 57 d0

        call Ld057_draw_diagonal_line  ; draws the first part of the bottom-right edge of the map in

#cff3

#6873

                                       ; the screen.

#cff3

#6873

3

11

    21 b8 d6

        ld hl, Ld6b8_diagonal_pattern2

#cff6

#6876

2

8

    06 04

        ld b, 4

#cff8

#6878

3

11

    11 12 65

        ld de, L5b00_double_buffer + 128 * 20 + 18

#cffb

#687b

3

11

    c3 57 d0

        jp Ld057_draw_diagonal_line  ; draws the second part of the bottom-right edge of the map in the

#cffe

#687e

                                     ; screen.

#cffe

#687e

#cffe

#687e

#cffe

#687e

    ; --------------------------------

#cffe

#687e

    Lcffe_clear_5b00_buffer:

#cffe

#687e

        ; clears memory to 0 in the following ranges:

#cffe

#687e

        ;   #5b00 - #6780 (6400 bytes)

#cffe

#687e

4

22

    ed 73 08 fd

        ld (Lfd08_stack_ptr_buffer), sp

#d002

#6882

3

11

    31 80 67

        ld sp, L6780_graphic_patterns  ; pointer to the definition of the " " character

#d005

#6885

2

8

    06 c6

        ld b, 198

#d007

#6887

3

11

    21 00 00

        ld hl, 0

#d00a

#688a

        ; This loop clears from #5b20 - #6780

#d00a

#688a

    Ld00a:

#d00a

#688a

1

12

    e5

        push hl

#d00b

#688b

1

12

    e5

        push hl

#d00c

#688c

1

12

    e5

        push hl

#d00d

#688d

1

12

    e5

        push hl

#d00e

#688e

1

12

    e5

        push hl

#d00f

#688f

1

12

    e5

        push hl

#d010

#6890

1

12

    e5

        push hl

#d011

#6891

1

12

    e5

        push hl

#d012

#6892

2

14/9

    10 f6

        djnz Ld00a

#d014

#6894

4

22

    ed 7b 08 fd

        ld sp, (Lfd08_stack_ptr_buffer)

#d018

#6898

        ; This clears from #5b00 - #5b20. Potential optimization: just set b above to 200, and remove

#d018

#6898

        ; the rest of this function.

#d018

#6898

3

11

    21 00 5b

        ld hl, L5b00_double_buffer

#d01b

#689b

3

11

    11 01 5b

        ld de, L5b00_double_buffer + 1

#d01e

#689e

3

11

    01 1f 00

        ld bc, 31

#d021

#68a1

2

11

    36 00

        ld (hl), 0

#d023

#68a3

2

23/18

    ed b0

        ldir

#d025

#68a5

1

11

    c9

        ret

#d026

#68a6

#d026

#68a6

#d026

#68a6

    ; --------------------------------

#d026

#68a6

    ; Draws the top-left diagonal black part of the screen (at an 8x8 pixel resolution, the pixel-level

#d026

#68a6

    ; edges are drawn later in the Ld057_draw_diagonal_line function).

#d026

#68a6

    Ld026_draw_top_left_diagonal_map_edge:

#d026

#68a6

2

8

    3e 0a

        ld a, 10

#d028

#68a8

3

14

    32 38 d0

        ld (Ld038_selfmodifying), a

#d02b

#68ab

3

14

    32 41 d0

        ld (Ld041_selfmodifying), a

#d02e

#68ae

3

11

    21 00 5b

        ld hl, L5b00_double_buffer

#d031

#68b1

2

8

    06 05

        ld b, 5

#d033

#68b3

    Ld033:

#d033

#68b3

1

12

    c5

        push bc

#d034

#68b4

2

8

    06 08

            ld b, 8

#d036

#68b6

    Ld036:

#d036

#68b6

1

12

    c5

            push bc

#d037

#68b7

    Ld038_selfmodifying: equ $ + 1

#d037

#68b7

2

8

    06 0a

                ld b, 10  ; mdl:self-modifying

#d039

#68b9

2

8

    3e ff

                ld a, 255

#d03b

#68bb

    Ld03b:

#d03b

#68bb

1

8

    77

                ld (hl), a

#d03c

#68bc

1

7

    23

                inc hl

#d03d

#68bd

2

14/9

    10 fc

                djnz Ld03b

#d03f

#68bf

1

11

    c1

            pop bc

#d040

#68c0

    Ld041_selfmodifying: equ $ + 1

#d040

#68c0

2

8

    3e 0a

            ld a, 10  ; mdl:self-modifying

#d042

#68c2

3

18

    cd 51 d3

            call Ld351_add_hl_a

#d045

#68c5

2

14/9

    10 ef

            djnz Ld036

#d047

#68c7

1

11

    c1

        pop bc

#d048

#68c8

1

12

    e5

        push hl

#d049

#68c9

3

11

    21 38 d0

            ld hl, Ld038_selfmodifying

#d04c

#68cc

1

12

    35

            dec (hl)

#d04d

#68cd

1

12

    35

            dec (hl)

#d04e

#68ce

3

11

    21 41 d0

            ld hl, Ld041_selfmodifying

#d051

#68d1

1

12

    34

            inc (hl)

#d052

#68d2

1

12

    34

            inc (hl)

#d053

#68d3

1

11

    e1

        pop hl

#d054

#68d4

2

14/9

    10 dd

        djnz Ld033

#d056

#68d6

1

11

    c9

        ret

#d057

#68d7

#d057

#68d7

#d057

#68d7

    ; --------------------------------

#d057

#68d7

    ; Draws one of the diagonal line patterns in either Ld6a8 or Ld6b8 to the rendering buffer

#d057

#68d7

    ; Input:

#d057

#68d7

    ; - hl: pointer to the source data (16 bytes)

#d057

#68d7

    ; - de: pointer to the destination buffer to start drawing. At each repetition, we go down 8

#d057

#68d7

    ;       pixels, and left 16 pixels (to draw a continuous diagonal line)

#d057

#68d7

    ; - b: number of times to copy the patterh (each time is a 16*8 pixel block).

#d057

#68d7

    Ld057_draw_diagonal_line:

#d057

#68d7

    Ld057_draw_diagonal_line_loop:

#d057

#68d7

1

12

    c5

        push bc

#d058

#68d8

1

12

    e5

        push hl

#d059

#68d9

3

11

    01 ff 08

            ld bc, #08ff  ; c to 255 (just a large enough value so that the auto decrement of ldi does

#d05c

#68dc

                          ; not get in the way of the djnz).

#d05c

#68dc

            ; Draw the diagonal pattern once (16x8 pixels).

#d05c

#68dc

    Ld05c_draw_diagonal_line_inner_loop:

#d05c

#68dc

2

18

    ed a0

            ldi

#d05e

#68de

2

18

    ed a0

            ldi

#d060

#68e0

2

8

    3e 12

            ld a, 18

#d062

#68e2

1

5

    83

            add a, e

#d063

#68e3

1

5

    5f

            ld e, a

#d064

#68e4

1

5

    7a

            ld a, d

#d065

#68e5

2

8

    ce 00

            adc a, 0

#d067

#68e7

1

5

    57

            ld d, a  ; de += 18 (i.e., 1 line down, since each line of the buffer is 20 bytes wide, and

#d068

#68e8

                     ; each ldi already increments in one).

#d068

#68e8

2

14/9

    10 f2

            djnz Ld05c_draw_diagonal_line_inner_loop

#d06a

#68ea

1

11

    e1

        pop hl

#d06b

#68eb

1

11

    c1

        pop bc

#d06c

#68ec

1

7

    1b

        dec de

#d06d

#68ed

1

7

    1b

        dec de

#d06e

#68ee

2

14/9

    10 e7

        djnz Ld057_draw_diagonal_line_loop

#d070

#68f0

1

11

    c9

        ret

#d071

#68f1

#d071

#68f1

#d071

#68f1

    ; --------------------------------

#d071

#68f1

    ; Copies the 160x160 pixels buffer from #5b00 to video memory

#d071

#68f1

    Ld071_copy_game_area_buffer_to_screen:

#d071

#68f1

3

11

    21 00 5b

        ld hl, L5b00_double_buffer

#d074

#68f4

3

11

    11 21 40

        ld de, L4000_VIDEOMEM_PATTERNS + 33

#d077

#68f7

2

8

    0e 14

        ld c, 20

#d079

#68f9

    Ld079_row_outer_loop:

#d079

#68f9

2

8

    06 08

        ld b, 8

#d07b

#68fb

    Ld07b_row_inner_loop:

#d07b

#68fb

1

12

    c5

        push bc

#d07c

#68fc

1

12

    d5

        push de

#d07d

#68fd

            ; copy one whole buffer row (20 bytes)

#d07d

#68fd

2

18

    ed a0

            ldi

#d07f

#68ff

2

18

    ed a0

            ldi

#d081

#6901

2

18

    ed a0

            ldi

#d083

#6903

2

18

    ed a0

            ldi

#d085

#6905

2

18

    ed a0

            ldi

#d087

#6907

2

18

    ed a0

            ldi

#d089

#6909

2

18

    ed a0

            ldi

#d08b

#690b

2

18

    ed a0

            ldi

#d08d

#690d

2

18

    ed a0

            ldi

#d08f

#690f

2

18

    ed a0

            ldi

#d091

#6911

2

18

    ed a0

            ldi

#d093

#6913

2

18

    ed a0

            ldi

#d095

#6915

2

18

    ed a0

            ldi

#d097

#6917

2

18

    ed a0

            ldi

#d099

#6919

2

18

    ed a0

            ldi

#d09b

#691b

2

18

    ed a0

            ldi

#d09d

#691d

2

18

    ed a0

            ldi

#d09f

#691f

2

18

    ed a0

            ldi

#d0a1

#6921

2

18

    ed a0

            ldi

#d0a3

#6923

2

18

    ed a0

            ldi

#d0a5

#6925

1

11

    d1

        pop de

#d0a6

#6926

1

11

    c1

        pop bc

#d0a7

#6927

1

5

    14

        inc d  ; next pixel row

#d0a8

#6928

2

14/9

    10 d1

        djnz Ld07b_row_inner_loop

#d0aa

#692a

        ; update the video pointer to the next block of 8 rows:

#d0aa

#692a

1

5

    7b

        ld a, e

#d0ab

#692b

2

8

    c6 20

        add a, 32

#d0ad

#692d

1

5

    5f

        ld e, a

#d0ae

#692e

2

13/8

    38 04

        jr c, Ld0b4

#d0b0

#6930

1

5

    7a

        ld a, d

#d0b1

#6931

2

8

    d6 08

        sub 8

#d0b3

#6933

1

5

    57

        ld d, a

#d0b4

#6934

    Ld0b4:

#d0b4

#6934

1

5

    0d

        dec c

#d0b5

#6935

3

11

    c2 79 d0

        jp nz, Ld079_row_outer_loop

#d0b8

#6938

1

11

    c9

        ret

#d0b9

#6939

#d0b9

#6939

#d0b9

#6939

    ; --------------------------------

#d0b9

#6939

    ; Clear the screen

#d0b9

#6939

    Ld0b9_clear_screen:

#d0b9

#6939

1

5

    af

        xor a

#d0ba

#693a

2

12

    d3 fe

        out (ULA_PORT), a  ; set border to black, speaker off

#d0bc

#693c

3

11

    21 00 40

        ld hl, #4000

#d0bf

#693f

3

11

    11 01 40

        ld de, #4001

#d0c2

#6942

3

11

    01 ff 1a

        ld bc, 6911

#d0c5

#6945

2

11

    36 00

        ld (hl), 0

#d0c7

#6947

2

23/18

    ed b0

        ldir

#d0c9

#6949

1

11

    c9

        ret

#d0ca

#694a

#d0ca

#694a

#d0ca

#694a

    ; --------------------------------

#d0ca

#694a

    Ld0ca_draw_in_game_screen_and_hud:

#d0ca

#694a

3

18

    cd b9 d0

        call Ld0b9_clear_screen

#d0cd

#694d

3

18

    cd bd cc

        call Lccbd_redraw_game_area

#d0d0

#6950

        ; Draw white frame around the game area:

#d0d0

#6950

        ; Top horizontal black line 1:

#d0d0

#6950

3

11

    21 00 40

        ld hl, L4000_VIDEOMEM_PATTERNS  ; (x, y) = (0, 0)

#d0d3

#6953

3

11

    11 01 40

        ld de, L4000_VIDEOMEM_PATTERNS + 1

#d0d6

#6956

3

11

    01 15 00

        ld bc, 21

#d0d9

#6959

2

11

    36 ff

        ld (hl), 255

#d0db

#695b

2

23/18

    ed b0

        ldir

#d0dd

#695d

        ; Top horizontal black line 2:

#d0dd

#695d

3

11

    21 01 47

        ld hl, L4000_VIDEOMEM_PATTERNS + #0701  ; (x, y) = (8, 7)

#d0e0

#6960

3

11

    11 02 47

        ld de, L4000_VIDEOMEM_PATTERNS + #0702

#d0e3

#6963

3

11

    01 13 00

        ld bc, 19

#d0e6

#6966

2

11

    36 ff

        ld (hl), 255

#d0e8

#6968

2

23/18

    ed b0

        ldir

#d0ea

#696a

        ; Bottom horizontal black line 1:

#d0ea

#696a

3

11

    21 a1 50

        ld hl, L4000_VIDEOMEM_PATTERNS + #10a1  ; (x, y) = (8, 168)

#d0ed

#696d

3

11

    11 a2 50

        ld de, L4000_VIDEOMEM_PATTERNS + #10a2

#d0f0

#6970

3

11

    01 13 00

        ld bc, 19

#d0f3

#6973

2

11

    36 ff

        ld (hl), 255

#d0f5

#6975

2

23/18

    ed b0

        ldir

#d0f7

#6977

        ; Bottom horizontal black line 2:

#d0f7

#6977

3

11

    21 a0 57

        ld hl, L4000_VIDEOMEM_PATTERNS + #17a0  ; (x, y) = (0, 175)

#d0fa

#697a

3

11

    11 a1 57

        ld de, L4000_VIDEOMEM_PATTERNS + #17a1

#d0fd

#697d

3

11

    01 15 00

        ld bc, 21

#d100

#6980

2

11

    36 ff

        ld (hl), 255

#d102

#6982

2

23/18

    ed b0

        ldir

#d104

#6984

        ; top-left corner:

#d104

#6984

3

11

    21 00 41

        ld hl, L4000_VIDEOMEM_PATTERNS + #0100  ; (x, y) = (0, 1)

#d107

#6987

2

8

    06 06

        ld b, 6

#d109

#6989

    Ld109_loop:

#d109

#6989

2

11

    36 80

        ld (hl), 128

#d10b

#698b

1

5

    24

        inc h

#d10c

#698c

2

14/9

    10 fb

        djnz Ld109_loop

#d10e

#698e

        ; top-right corner:

#d10e

#698e

3

11

    21 15 41

        ld hl, L4000_VIDEOMEM_PATTERNS + #0115  ; (x, y) = (168, 1)

#d111

#6991

2

8

    06 06

        ld b, 6

#d113

#6993

    Ld113_loop:

#d113

#6993

2

11

    36 01

        ld (hl), 1

#d115

#6995

1

5

    24

        inc h

#d116

#6996

2

14/9

    10 fb

        djnz Ld113_loop

#d118

#6998

        ; bottom-left corner:

#d118

#6998

3

11

    21 a0 50

        ld hl, L4000_VIDEOMEM_PATTERNS + #10a0  ; (x, y) = (0, 168)

#d11b

#699b

2

8

    06 07

        ld b, 7

#d11d

#699d

    Ld11d_loop:

#d11d

#699d

2

11

    36 80

        ld (hl), 128

#d11f

#699f

1

5

    24

        inc h

#d120

#69a0

2

14/9

    10 fb

        djnz Ld11d_loop

#d122

#69a2

        ; bottom-right corner:

#d122

#69a2

3

11

    21 b5 50

        ld hl, L4000_VIDEOMEM_PATTERNS + #10b5  ; (x, y) = (168, 168)

#d125

#69a5

2

8

    06 07

        ld b, 7

#d127

#69a7

    Ld127_loop:

#d127

#69a7

2

11

    36 01

        ld (hl), 1

#d129

#69a9

1

5

    24

        inc h

#d12a

#69aa

2

14/9

    10 fb

        djnz Ld127_loop

#d12c

#69ac

        ; left bar:

#d12c

#69ac

3

11

    21 00 47

        ld hl, L4000_VIDEOMEM_PATTERNS + #0700  ; (x, y) = (0, 7)

#d12f

#69af

2

8

    06 a2

        ld b, 162

#d131

#69b1

    Ld131_loop:

#d131

#69b1

2

11

    36 81

        ld (hl), 129

#d133

#69b3

3

18

    cd 2a d3

        call Ld32a_inc_video_ptr_y_hl

#d136

#69b6

2

14/9

    10 f9

        djnz Ld131_loop

#d138

#69b8

        ; right bar:

#d138

#69b8

3

11

    21 15 47

        ld hl, L4000_VIDEOMEM_PATTERNS + #0715  ; (x, y) = (128, 7)

#d13b

#69bb

2

8

    06 a2

        ld b, 162

#d13d

#69bd

    Ld13d_loop:

#d13d

#69bd

2

11

    36 81

        ld (hl), 129

#d13f

#69bf

3

18

    cd 2a d3

        call Ld32a_inc_video_ptr_y_hl

#d142

#69c2

2

14/9

    10 f9

        djnz Ld13d_loop

#d144

#69c4

#d144

#69c4

        ; Set the screen attributes:

#d144

#69c4

        ; Whole thing to WHITE over BLACK to start:

#d144

#69c4

3

11

    21 00 58

        ld hl, L5800_VIDEOMEM_ATTRIBUTES

#d147

#69c7

3

11

    11 01 58

        ld de, L5800_VIDEOMEM_ATTRIBUTES + 1

#d14a

#69ca

3

11

    01 ff 02

        ld bc, 767

#d14d

#69cd

2

11

    36 07

        ld (hl), COLOR_WHITE

#d14f

#69cf

2

23/18

    ed b0

        ldir

#d151

#69d1

        ; Black over white for the frame around the game (top)""

#d151

#69d1

        ; Potential optimization: If we change the pixels in the border drawing code above, we can

#d151

#69d1

        ; remove all of the lines below for the frame attributes

#d151

#69d1

        ; Top line:

#d151

#69d1

3

11

    21 00 58

        ld hl, L5800_VIDEOMEM_ATTRIBUTES

#d154

#69d4

3

11

    11 01 58

        ld de, L5800_VIDEOMEM_ATTRIBUTES + 1

#d157

#69d7

3

11

    01 15 00

        ld bc, 21

#d15a

#69da

2

11

    36 78

        ld (hl), COLOR_BRIGHT + COLOR_WHITE * PAPER_COLOR_MULTIPLIER

#d15c

#69dc

2

23/18

    ed b0

        ldir

#d15e

#69de

        ; Bottom line:

#d15e

#69de

3

11

    21 a0 5a

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #02a0

#d161

#69e1

3

11

    11 a1 5a

        ld de, L5800_VIDEOMEM_ATTRIBUTES + #02a0 + 1

#d164

#69e4

3

11

    01 15 00

        ld bc, 21

#d167

#69e7

2

11

    36 78

        ld (hl), COLOR_BRIGHT + COLOR_WHITE * PAPER_COLOR_MULTIPLIER

#d169

#69e9

2

23/18

    ed b0

        ldir

#d16b

#69eb

        ; Side bars:

#d16b

#69eb

3

11

    21 20 58

        ld hl, 22560

#d16e

#69ee

2

8

    06 14

        ld b, 20

#d170

#69f0

    Ld170_loop:

#d170

#69f0

2

11

    36 78

        ld (hl), COLOR_BRIGHT + COLOR_WHITE * PAPER_COLOR_MULTIPLIER

#d172

#69f2

2

8

    3e 15

        ld a, 21

#d174

#69f4

3

18

    cd 51 d3

        call Ld351_add_hl_a

#d177

#69f7

2

11

    36 78

        ld (hl), COLOR_BRIGHT + COLOR_WHITE * PAPER_COLOR_MULTIPLIER

#d179

#69f9

2

8

    3e 0b

        ld a, 11

#d17b

#69fb

3

18

    cd 51 d3

        call Ld351_add_hl_a

#d17e

#69fe

2

14/9

    10 f0

        djnz Ld170_loop

#d180

#6a00

#d180

#6a00

        ; In-game screen yellow color:

#d180

#6a00

3

11

    21 21 58

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0021

#d183

#6a03

3

11

    01 14 14

        ld bc, #1414  ; 20, 20

#d186

#6a06

    Ld186_outer_loop:

#d186

#6a06

1

12

    c5

        push bc

#d187

#6a07

    Ld187_inner_loop:

#d187

#6a07

2

11

    36 70

            ld (hl), COLOR_BRIGHT + COLOR_YELLOW * PAPER_COLOR_MULTIPLIER

#d189

#6a09

1

7

    23

            inc hl

#d18a

#6a0a

2

14/9

    10 fb

            djnz Ld187_inner_loop

#d18c

#6a0c

1

11

    c1

        pop bc

#d18d

#6a0d

2

8

    3e 0c

        ld a, 12

#d18f

#6a0f

3

18

    cd 51 d3

        call Ld351_add_hl_a

#d192

#6a12

1

5

    0d

        dec c

#d193

#6a13

2

13/8

    20 f1

        jr nz, Ld186_outer_loop

#d195

#6a15

#d195

#6a15

        ; blue 3-d effect in the bottom-right of the map:

#d195

#6a15

        ; Yellow -> blue border:

#d195

#6a15

2

8

    06 04

        ld b, 4

#d197

#6a17

3

11

    21 33 5a

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0233

#d19a

#6a1a

    Ld19a_loop:

#d19a

#6a1a

2

11

    36 71

        ld (hl), COLOR_BRIGHT + COLOR_YELLOW * PAPER_COLOR_MULTIPLIER + COLOR_BLUE

#d19c

#6a1c

1

7

    23

        inc hl

#d19d

#6a1d

2

11

    36 71

        ld (hl), COLOR_BRIGHT + COLOR_YELLOW * PAPER_COLOR_MULTIPLIER + COLOR_BLUE

#d19f

#6a1f

2

8

    3e 1d

        ld a, 29

#d1a1

#6a21

3

18

    cd 51 d3

        call Ld351_add_hl_a

#d1a4

#6a24

2

14/9

    10 f4

        djnz Ld19a_loop

#d1a6

#6a26

        ; Blue -> black border:

#d1a6

#6a26

3

11

    21 53 5a

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0253

#d1a9

#6a29

2

11

    36 41

        ld (hl), COLOR_BRIGHT + COLOR_BLUE

#d1ab

#6a2b

1

7

    23

        inc hl

#d1ac

#6a2c

2

11

    36 41

        ld (hl), COLOR_BRIGHT + COLOR_BLUE

#d1ae

#6a2e

3

11

    21 71 5a

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #0271

#d1b1

#6a31

2

8

    06 04

        ld b, 4

#d1b3

#6a33

    Ld1b3_loop:

#d1b3

#6a33

2

11

    36 41

        ld (hl), COLOR_BRIGHT + COLOR_BLUE

#d1b5

#6a35

1

7

    23

        inc hl

#d1b6

#6a36

2

14/9

    10 fb

        djnz Ld1b3_loop

#d1b8

#6a38

3

11

    21 8f 5a

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #028f

#d1bb

#6a3b

2

8

    06 06

        ld b, 6

#d1bd

#6a3d

    Ld1bd_loop:

#d1bd

#6a3d

2

11

    36 41

        ld (hl), COLOR_BRIGHT + COLOR_BLUE

#d1bf

#6a3f

1

7

    23

        inc hl

#d1c0

#6a40

2

14/9

    10 fb

        djnz Ld1bd_loop

#d1c2

#6a42

#d1c2

#6a42

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#d1c5

#6a45

        ; Script start:

#d1c5

#6a45

2

            db CMD_SET_ATTRIBUTE, #57

#d1c7

#6a47

3

            db CMD_SET_POSITION, #00, #16

#d1ca

#6a4a

2

            db CMD_SET_SCALE, #00

#d1cc

#6a4c

5

            db " DAY:"

#d1d1

#6a51

1

            db CMD_NEXT_LINE

#d1d2

#6a52

5

            db "TIME:"

#d1d7

#6a57

3

            db CMD_SET_POSITION, #16, #00

#d1da

#6a5a

2

            db CMD_SET_SCALE, #21

#d1dc

#6a5c

2

            db CMD_SET_ATTRIBUTE, #45

#d1de

#6a5e

6

            db "RADAR:"

#d1e4

#6a64

1

            db CMD_END

#d1e5

#6a65

        ; Script end:

#d1e5

#6a65

    Ld1e5_draw_in_game_right_hud:

#d1e5

#6a65

3

18

    cd f6 d2

        call Ld2f6_clear_in_game_right_hud

#d1e8

#6a68

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#d1eb

#6a6b

        ; Script start:

#d1eb

#6a6b

3

            db CMD_SET_POSITION, #03, #16

#d1ee

#6a6e

2

            db CMD_SET_ATTRIBUTE, #46

#d1f0

#6a70

8

            db "  STATUS"

#d1f8

#6a78

1

            db CMD_NEXT_LINE

#d1f9

#6a79

10

            db "INSG  HUMN"

#d203

#6a83

3

            db CMD_SET_POSITION, #06, #17

#d206

#6a86

2

            db CMD_SET_ATTRIBUTE, #45

#d208

#6a88

8

            db "WARBASES"

#d210

#6a90

1

            db CMD_NEXT_LINE

#d211

#6a91

8

            db "ELECTR'S"

#d219

#6a99

1

            db CMD_NEXT_LINE

#d21a

#6a9a

7

            db "NUCLEAR"

#d221

#6aa1

1

            db CMD_NEXT_LINE

#d222

#6aa2

7

            db "PHASERS"

#d229

#6aa9

1

            db CMD_NEXT_LINE

#d22a

#6aaa

8

            db "MISSILES"

#d232

#6ab2

1

            db CMD_NEXT_LINE

#d233

#6ab3

7

            db " CANNON"

#d23a

#6aba

1

            db CMD_NEXT_LINE

#d23b

#6abb

7

            db "CHASSIS"

#d242

#6ac2

1

            db CMD_NEXT_LINE

#d243

#6ac3

7

            db " ROBOTS"

#d24a

#6aca

3

            db CMD_SET_POSITION, #0f, #17

#d24d

#6acd

2

            db CMD_SET_ATTRIBUTE, #46

#d24f

#6acf

9

            db "RESOURCES"

#d258

#6ad8

1

            db CMD_NEXT_LINE

#d259

#6ad9

1

            db CMD_NEXT_LINE

#d25a

#6ada

2

            db CMD_SET_ATTRIBUTE, #44

#d25c

#6adc

7

            db "GENERAL"

#d263

#6ae3

1

            db CMD_NEXT_LINE

#d264

#6ae4

7

            db "ELECTR'"

#d26b

#6aeb

1

            db CMD_NEXT_LINE

#d26c

#6aec

7

            db "NUCLEAR"

#d273

#6af3

1

            db CMD_NEXT_LINE

#d274

#6af4

7

            db "PHASERS"

#d27b

#6afb

1

            db CMD_NEXT_LINE

#d27c

#6afc

7

            db "MISSILE"

#d283

#6b03

1

            db CMD_NEXT_LINE

#d284

#6b04

6

            db "CANNON"

#d28a

#6b0a

1

            db CMD_NEXT_LINE

#d28b

#6b0b

7

            db "CHASSIS"

#d292

#6b12

1

            db CMD_END

#d293

#6b13

        ; Script end:

#d293

#6b13

    Ld293_update_stats_in_right_hud:

#d293

#6b13

3

14

    3a 39 fd

        ld a, (Lfd39_current_in_game_right_hud)

#d296

#6b16

1

5

    b7

        or a

#d297

#6b17

1

12/6

    c0

        ret nz  ; If the stats are not to be displayed now, just return

#d298

#6b18

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#d29b

#6b1b

        ; Script start:

#d29b

#6b1b

3

            db CMD_SET_POSITION, #10, #1e

#d29e

#6b1e

2

            db CMD_SET_ATTRIBUTE, #4e

#d2a0

#6b20

2

            db CMD_SET_SCALE, #00

#d2a2

#6b22

1

            db CMD_END

#d2a3

#6b23

        ; Script end:

#d2a3

#6b23

        ; Print player resources:

#d2a3

#6b23

3

11

    21 22 fd

        ld hl, Lfd22_player1_resource_counts

#d2a6

#6b26

2

8

    06 07

        ld b, 7

#d2a8

#6b28

    Ld2a8_player_resources_loop:

#d2a8

#6b28

1

12

    c5

        push bc

#d2a9

#6b29

1

12

    e5

            push hl

#d2aa

#6b2a

3

18

    cd 70 d4

                call Ld470_execute_command_3_next_line

#d2ad

#6b2d

1

11

    e1

            pop hl

#d2ae

#6b2e

1

8

    7e

            ld a, (hl)

#d2af

#6b2f

1

7

    23

            inc hl

#d2b0

#6b30

1

12

    e5

            push hl

#d2b1

#6b31

3

18

    cd e5 d3

                call Ld3e5_render_8bit_number

#d2b4

#6b34

1

11

    e1

            pop hl

#d2b5

#6b35

1

11

    c1

        pop bc

#d2b6

#6b36

2

14/9

    10 f0

        djnz Ld2a8_player_resources_loop

#d2b8

#6b38

#d2b8

#6b38

        ; Print AI stats:

#d2b8

#6b38

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#d2bb

#6b3b

        ; Script start:

#d2bb

#6b3b

3

            db CMD_SET_POSITION, #06, #16

#d2be

#6b3e

2

            db CMD_SET_ATTRIBUTE, #47

#d2c0

#6b40

1

            db CMD_END

#d2c1

#6b41

        ; Script end:

#d2c1

#6b41

3

11

    21 42 fd

        ld hl, Lfd42_player2_base_factory_counts

#d2c4

#6b44

3

18

    cd e3 d2

        call Ld2e3_draw_warbase_factory_counts

#d2c7

#6b47

1

8

    7e

        ld a, (hl)

#d2c8

#6b48

3

18

    cd ec d3

        call Ld3ec_render_8bit_number_with_leading_zeroes

#d2cb

#6b4b

#d2cb

#6b4b

        ; Print Player stats:

#d2cb

#6b4b

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#d2ce

#6b4e

        ; Script start:

#d2ce

#6b4e

3

            db CMD_SET_POSITION, #06, #1f

#d2d1

#6b51

1

            db CMD_END

#d2d2

#6b52

        ; Script end

#d2d2

#6b52

3

11

    21 3a fd

        ld hl, Lfd3a_player1_base_factory_counts

#d2d5

#6b55

3

18

    cd e3 d2

        call Ld2e3_draw_warbase_factory_counts

#d2d8

#6b58

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#d2db

#6b5b

        ; Script start:

#d2db

#6b5b

3

            db CMD_SET_POSITION, #0d, #1e

#d2de

#6b5e

1

            db CMD_END

#d2df

#6b5f

        ; Script end

#d2df

#6b5f

1

8

    7e

        ld a, (hl)

#d2e0

#6b60

3

11

    c3 ec d3

        jp Ld3ec_render_8bit_number_with_leading_zeroes

#d2e3

#6b63

#d2e3

#6b63

#d2e3

#6b63

    ; --------------------------------

#d2e3

#6b63

    ; Draws the number of warbases and factories of each type a given player owns.

#d2e3

#6b63

    ; Inputs:

#d2e3

#6b63

    ; - hl: counts pointer

#d2e3

#6b63

    Ld2e3_draw_warbase_factory_counts:

#d2e3

#6b63

2

8

    06 07

        ld b, 7

#d2e5

#6b65

    Ld2e5_draw_warbase_factory_counts_loop:

#d2e5

#6b65

1

12

    c5

        push bc

#d2e6

#6b66

1

8

    7e

            ld a, (hl)

#d2e7

#6b67

1

7

    23

            inc hl

#d2e8

#6b68

2

8

    c6 30

            add a, 48

#d2ea

#6b6a

3

18

    cd 27 d4

            call Ld427_draw_character_saving_registers

#d2ed

#6b6d

1

12

    e5

            push hl

#d2ee

#6b6e

3

18

    cd 70 d4

                call Ld470_execute_command_3_next_line

#d2f1

#6b71

1

11

    e1

            pop hl

#d2f2

#6b72

1

11

    c1

        pop bc

#d2f3

#6b73

2

14/9

    10 f0

        djnz Ld2e5_draw_warbase_factory_counts_loop

#d2f5

#6b75

1

11

    c9

        ret

#d2f6

#6b76

#d2f6

#6b76

#d2f6

#6b76

    ; --------------------------------

#d2f6

#6b76

    ; Clears the right-hand-size hud in-game, except for the day and time.

#d2f6

#6b76

    Ld2f6_clear_in_game_right_hud:

#d2f6

#6b76

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#d2f9

#6b79

        ; Script start:

#d2f9

#6b79

3

            db CMD_SET_POSITION, #02, #16

#d2fc

#6b7c

2

            db CMD_SET_SCALE, #00

#d2fe

#6b7e

2

            db CMD_SET_ATTRIBUTE, #00

#d300

#6b80

1

            db CMD_END

#d301

#6b81

        ; Script end:

#d301

#6b81

2

8

    06 16

        ld b, 22  ; Clears 22 lines (everything but the top two, which is the day and time):

#d303

#6b83

    Ld303_loop:

#d303

#6b83

3

18

    cd 2d d4

        call Ld42d_execute_ui_script

#d306

#6b86

        ; Script start:

#d306

#6b86

10

            db "          "

#d310

#6b90

1

            db CMD_NEXT_LINE

#d311

#6b91

1

            db CMD_END

#d312

#6b92

        ; Script end:

#d312

#6b92

2

14/9

    10 ef

        djnz Ld303_loop

#d314

#6b94

1

11

    c9

        ret

#d315

#6b95

#d315

#6b95

#d315

#6b95

    ; --------------------------------

#d315

#6b95

    ; Input:

#d315

#6b95

    ; - de: video pointer to draw

#d315

#6b95

    ; - hl: sprite ptr in RAM

#d315

#6b95

    ; - b: prite width in bytes

#d315

#6b95

    ; - c: sprite height in pixels

#d315

#6b95

    Ld315_draw_masked_sprite_bottom_up:

#d315

#6b95

    Ld315_draw_masked_sprite_x_loop:

#d315

#6b95

1

12

    c5

        push bc

#d316

#6b96

1

12

    d5

        push de

#d317

#6b97

    Ld317_draw_masked_sprite_y_loop:

#d317

#6b97

1

8

    1a

            ld a, (de)  ; get a pixel from the screen

#d318

#6b98

1

8

    a6

            and (hl)  ; and mask (clear some pixels)

#d319

#6b99

1

7

    23

            inc hl

#d31a

#6b9a

1

8

    b6

            or (hl)  ; or mask (draw pixels)

#d31b

#6b9b

1

8

    12

            ld (de), a  ; write back to the screen

#d31c

#6b9c

1

7

    23

            inc hl  ; next pixel

#d31d

#6b9d

1

7

    13

            inc de

#d31e

#6b9e

2

14/9

    10 f7

            djnz Ld317_draw_masked_sprite_y_loop

#d320

#6ba0

1

11

    d1

        pop de

#d321

#6ba1

1

11

    c1

        pop bc

#d322

#6ba2

3

18

    cd 39 d3

        call Ld339_dec_video_ptr_y_de

#d325

#6ba5

1

5

    0d

        dec c

#d326

#6ba6

3

11

    c2 15 d3

        jp nz, Ld315_draw_masked_sprite_x_loop

#d329

#6ba9

1

11

    c9

        ret

#d32a

#6baa

#d32a

#6baa

#d32a

#6baa

    ; --------------------------------

#d32a

#6baa

    ; Move a pointer 1 pixel down in the screen

#d32a

#6baa

    ; hl: video memory pointer as: 010ccaaa bbbxxxxx

#d32a

#6baa

    ;     The y coordinate is ccbbbaaa

#d32a

#6baa

    Ld32a_inc_video_ptr_y_hl:

#d32a

#6baa

1

5

    24

        inc h

#d32b

#6bab

2

8

    3e 07

        ld a, #07

#d32d

#6bad

1

5

    a4

        and h

#d32e

#6bae

1

12/6

    c0

        ret nz

#d32f

#6baf

1

5

    7d

        ld a, l

#d330

#6bb0

2

8

    c6 20

        add a, 32

#d332

#6bb2

1

5

    6f

        ld l, a

#d333

#6bb3

1

12/6

    d8

        ret c

#d334

#6bb4

1

5

    7c

        ld a, h

#d335

#6bb5

2

8

    d6 08

        sub 8

#d337

#6bb7

1

5

    67

        ld h, a

#d338

#6bb8

1

11

    c9

        ret

#d339

#6bb9

#d339

#6bb9

#d339

#6bb9

    ; --------------------------------

#d339

#6bb9

    ; Move a pointer 1 pixel up in the screen

#d339

#6bb9

    ; hl: video memory pointer as: 010ccaaa bbbxxxxx

#d339

#6bb9

    ;     The y coordinate is ccbbbaaa

#d339

#6bb9

    Ld339_dec_video_ptr_y_de:

#d339

#6bb9

1

5

    7a

        ld a, d

#d33a

#6bba

1

5

    15

        dec d

#d33b

#6bbb

2

8

    e6 07

        and #07

#d33d

#6bbd

1

12/6

    c0

        ret nz

#d33e

#6bbe

1

5

    7b

        ld a, e

#d33f

#6bbf

2

8

    d6 20

        sub 32

#d341

#6bc1

1

5

    5f

        ld e, a

#d342

#6bc2

1

12/6

    d8

        ret c

#d343

#6bc3

1

5

    7a

        ld a, d

#d344

#6bc4

2

8

    c6 08

        add a, 8

#d346

#6bc6

1

5

    57

        ld d, a

#d347

#6bc7

1

11

    c9

        ret

#d348

#6bc8

#d348

#6bc8

#d348

#6bc8

    ; --------------------------------

#d348

#6bc8

    ; input:

#d348

#6bc8

    ; - a, hl

#d348

#6bc8

    ; output:

#d348

#6bc8

    ; - hl = (hl + a*2)

#d348

#6bc8

    Ld348_get_ptr_from_table:

#d348

#6bc8

1

5

    87

        add a, a

#d349

#6bc9

3

18

    cd 51 d3

        call Ld351_add_hl_a

#d34c

#6bcc

1

8

    7e

        ld a, (hl)

#d34d

#6bcd

1

7

    23

        inc hl

#d34e

#6bce

1

8

    66

        ld h, (hl)

#d34f

#6bcf

1

5

    6f

        ld l, a

#d350

#6bd0

1

11

    c9

        ret

#d351

#6bd1

#d351

#6bd1

#d351

#6bd1

    ; --------------------------------

#d351

#6bd1

    ; hl = hl + a

#d351

#6bd1

    Ld351_add_hl_a:

#d351

#6bd1

1

5

    85

        add a, l

#d352

#6bd2

1

5

    6f

        ld l, a

#d353

#6bd3

1

5

    7c

        ld a, h

#d354

#6bd4

2

8

    ce 00

        adc a, 0

#d356

#6bd6

1

5

    67

        ld h, a

#d357

#6bd7

1

11

    c9

        ret

#d358

#6bd8

#d358

#6bd8

#d358

#6bd8

    ; --------------------------------

#d358

#6bd8

    ; Random number generation: uses a 4 byte seed buffer in #fd00

#d358

#6bd8

    ; output:

#d358

#6bd8

    ; - a: next random number

#d358

#6bd8

    ; preserves: hl

#d358

#6bd8

    Ld358_random:

#d358

#6bd8

1

12

    e5

        push hl

#d359

#6bd9

3

11

    21 00 fd

            ld hl, Lfd00_random_seed

#d35c

#6bdc

1

8

    7e

            ld a, (hl)

#d35d

#6bdd

2

8

    e6 48

            and 72

#d35f

#6bdf

2

8

    c6 38

            add a, 56

#d361

#6be1

1

5

    07

            rlca

#d362

#6be2

1

5

    07

            rlca

#d363

#6be3

2

8

    2e 03

            ld l, 3

#d365

#6be5

2

17

    cb 16

            rl (hl)

#d367

#6be7

1

5

    2d

            dec l

#d368

#6be8

2

17

    cb 16

            rl (hl)

#d36a

#6bea

1

5

    2d

            dec l

#d36b

#6beb

2

17

    cb 16

            rl (hl)

#d36d

#6bed

1

5

    2d

            dec l

#d36e

#6bee

2

17

    cb 16

            rl (hl)

#d370

#6bf0

    Ld370_selfmodifying: equ $ + 1

#d370

#6bf0

2

8

    2e 00

            ld l, 0  ; mdl:self-modifying

#d372

#6bf2

1

8

    7e

            ld a, (hl)

#d373

#6bf3

2

8

    e6 03

            and 3

#d375

#6bf5

1

5

    6f

            ld l, a

#d376

#6bf6

3

14

    32 71 d3

            ld (Ld370_selfmodifying), a  ; self-modifying: overwrites the argument of the instruction

#d379

#6bf9

                                           ; marked above.

#d379

#6bf9

1

8

    7e

            ld a, (hl)

#d37a

#6bfa

1

11

    e1

        pop hl

#d37b

#6bfb

1

11

    c9

        ret

#d37c

#6bfc

#d37c

#6bfc

#d37c

#6bfc

    ; --------------------------------

#d37c

#6bfc

    ; Reads the keyboard and joystick input, and stores the state in (Lfd0c_keyboard_state).

#d37c

#6bfc

    ; - If the user presses the pause key, this function is blocked until the user presses it again.

#d37c

#6bfc

    ; Output:

#d37c

#6bfc

    ; - a: keyboard state (also stored in "Lfd0c_keyboard_state")

#d37c

#6bfc

    Ld37c_read_keyboard_joystick_input:

#d37c

#6bfc

3

18

    cd 8a d3

        call Ld38a_read_keyboard_joystick_input_internal

#d37f

#6bff

1

5

    b7

        or a

#d380

#6c00

1

12/6

    f0

        ret p  ; if pause key was not pressed, return

#d381

#6c01

    Ld381_pause:

#d381

#6c01

3

18

    cd 8a d3

        call Ld38a_read_keyboard_joystick_input_internal

#d384

#6c04

1

5

    b7

        or a

#d385

#6c05

2

13/8

    28 fa

        jr z, Ld381_pause

#d387

#6c07

3

11

    fa 81 d3

        jp m, Ld381_pause

#d38a

#6c0a

#d38a

#6c0a

    Ld38a_read_keyboard_joystick_input_internal:

#d38a

#6c0a

3

11

    21 cc d3

        ld hl, Ld3cc_key_pause

#d38d

#6c0d

2

8

    0e 01

        ld c, 1  ; set a 1 in the least significant bit, so that when we rotate this 8 times,

#d38f

#6c0f

                 ; the carry flag is set to indicate end of iteration

#d38f

#6c0f

    Ld38f_key_loop:

#d38f

#6c0f

1

8

    7e

        ld a, (hl)  ; keyboard matrix row to read

#d390

#6c10

1

7

    23

        inc hl

#d391

#6c11

2

12

    db fe

        in a, (ULA_PORT)  ; a = high byte, ULA_PORT = low byte

#d393

#6c13

1

8

    a6

        and (hl)  ; mask to isolate the desired key

#d394

#6c14

1

7

    23

        inc hl

#d395

#6c15

1

7

    23

        inc hl

#d396

#6c16

        ; at this point carry flag is always reset ("inc" does not touch it, and "and" resets it)

#d396

#6c16

2

13/8

    20 01

        jr nz, Ld399_key_not_pressed

#d398

#6c18

1

5

    3f

        ccf  ; set carry flag

#d399

#6c19

    Ld399_key_not_pressed:

#d399

#6c19

2

10

    cb 11

        rl c  ; add the bit corresponding to one key to "c" (which was in the carry flag)

#d39b

#6c1b

2

13/8

    30 f2

        jr nc, Ld38f_key_loop  ; carry flag will be set after 8 loops (checked al 8 keys)

#d39d

#6c1d

3

14

    3a e4 d3

        ld a, (Ld3e4_input_type)

#d3a0

#6c20

2

8

    fe 02

        cp INPUT_KEMPSTON

#d3a2

#6c22

2

13/8

    28 07

        jr z, Ld3ab_read_kempston

#d3a4

#6c24

2

8

    fe 03

        cp INPUT_INTERFACE2

#d3a6

#6c26

2

13/8

    28 0a

        jr z, Ld3b2_read_interface2

#d3a8

#6c28

1

5

    af

        xor a

#d3a9

#6c29

2

13

    18 1c

        jr Ld3c7_all_inputs_read

#d3ab

#6c2b

    Ld3ab_read_kempston:

#d3ab

#6c2b

1

5

    af

        xor a

#d3ac

#6c2c

2

12

    db 1f

        in a, (KEMPSTON_JOYSTICK_PORT)  ; read the kempston joystick state

#d3ae

#6c2e

2

8

    e6 1f

        and #1f

#d3b0

#6c30

2

13

    18 15

        jr Ld3c7_all_inputs_read

#d3b2

#6c32

    Ld3b2_read_interface2:

#d3b2

#6c32

2

8

    3e ef

        ld a, INTERFACE2_JOYSTICK_PORT_MSB  ; read the interface2 joystick state.

#d3b4

#6c34

2

12

    db fe

        in a, (ULA_PORT)  ; a = high byte, ULA_PORT = low byte

#d3b6

#6c36

1

5

    2f

        cpl

#d3b7

#6c37

2

8

    e6 1f

        and #1f

#d3b9

#6c39

        ; reorder the interface2 bits so they are in the same order as they keyboard ones:

#d3b9

#6c39

1

5

    47

        ld b, a

#d3ba

#6c3a

1

5

    af

        xor a

#d3bb

#6c3b

2

10

    cb 38

        srl b

#d3bd

#6c3d

1

5

    17

        rla

#d3be

#6c3e

2

10

    cb 38

        srl b

#d3c0

#6c40

1

5

    17

        rla

#d3c1

#6c41

2

10

    cb 38

        srl b

#d3c3

#6c43

1

5

    17

        rla

#d3c4

#6c44

1

5

    17

        rla

#d3c5

#6c45

1

5

    17

        rla

#d3c6

#6c46

1

5

    b0

        or b

#d3c7

#6c47

    Ld3c7_all_inputs_read:

#d3c7

#6c47

1

5

    b1

        or c  ; potentially add joystick inputs over to the keyboard ones

#d3c8

#6c48

3

14

    32 0c fd

        ld (Lfd0c_keyboard_state), a

#d3cb

#6c4b

1

11

    c9

        ret

#d3cc

#6c4c

#d3cc

#6c4c

#d3cc

#6c4c

    ; --------------------------------

#d3cc

#6c4c

    ; Array storing the redefined keys:

#d3cc

#6c4c

    ; - first byte is the high byte of the address to read from to get the correct keyboard matrix row.

#d3cc

#6c4c

    ; - the second is the mask we need to apply to the value read from the keyboard matrix to isolate

#d3cc

#6c4c

    ;   the key.

#d3cc

#6c4c

    ; - third value is the ascii representation of the key.

#d3cc

#6c4c

    Ld3cc_key_pause:

#d3cc

#6c4c

3

        db #f7, #01, #31  ; 247,  1, "1"

#d3cf

#6c4f

    Ld3cf_key_abort:

#d3cf

#6c4f

3

        db #df, #04, #49  ; 223,  4, "I"

#d3d2

#6c52

    Ld3d2_key_save:

#d3d2

#6c52

3

        db #f7, #10, #35  ; 247, 16, "5"

#d3d5

#6c55

    Ld3d5_key_fire:

#d3d5

#6c55

3

        db #7f, #02, #82  ; 127,  2, 130

#d3d8

#6c58

    Ld3d8_key_up:

#d3d8

#6c58

3

        db #fb, #01, #51  ; 251,  1, "Q"

#d3db

#6c5b

    Ld3db_key_down:

#d3db

#6c5b

3

        db #fd, #01, #41  ; 253,  1, "A"

#d3de

#6c5e

    Ld3de_key_left:

#d3de

#6c5e

3

        db #df, #02, #4f  ; 223,  2, "O"

#d3e1

#6c61

    Ld3e1_key_right:

#d3e1

#6c61

3

        db #df, #01, #50  ; 223,  1, "P"

#d3e4

#6c64

    Ld3e4_input_type:

#d3e4

#6c64

1

        db #01

#d3e5

#6c65

#d3e5

#6c65

#d3e5

#6c65

    ; --------------------------------

#d3e5

#6c65

    Ld3e5_render_8bit_number:

#d3e5

#6c65

1

5

    6f

        ld l, a

#d3e6

#6c66

2

8

    26 00

        ld h, 0

#d3e8

#6c68

2

8

    1e 20

        ld e, " "

#d3ea

#6c6a

2

13

    18 1b

        jr Ld407_render_16bit_number_2digits

#d3ec

#6c6c

#d3ec

#6c6c

#d3ec

#6c6c

    ; --------------------------------

#d3ec

#6c6c

    Ld3ec_render_8bit_number_with_leading_zeroes:

#d3ec

#6c6c

1

5

    6f

        ld l, a

#d3ed

#6c6d

2

8

    26 00

        ld h, 0

#d3ef

#6c6f

2

8

    1e 00

        ld e, 0

#d3f1

#6c71

2

13

    18 14

        jr Ld407_render_16bit_number_2digits

#d3f3

#6c73

#d3f3

#6c73

#d3f3

#6c73

    ; --------------------------------

#d3f3

#6c73

    ; Draws a 16bit number to screen.

#d3f3

#6c73

    ; input:

#d3f3

#6c73

    ; - hl: the number to draw

#d3f3

#6c73

    Ld3f3_render_16bit_number:

#d3f3

#6c73

3

11

    01 f0 d8

        ld bc, -10000

#d3f6

#6c76

2

8

    1e 20

        ld e, " "

#d3f8

#6c78

3

18

    cd 13 d4

        call Ld413_render_16bit_number_one_digit

#d3fb

#6c7b

3

11

    01 18 fc

        ld bc, -1000

#d3fe

#6c7e

3

18

    cd 13 d4

        call Ld413_render_16bit_number_one_digit

#d401

#6c81

    Ld401_render_16bit_number_3digits:

#d401

#6c81

3

11

    01 9c ff

        ld bc, -100

#d404

#6c84

3

18

    cd 13 d4

        call Ld413_render_16bit_number_one_digit

#d407

#6c87

    Ld407_render_16bit_number_2digits:

#d407

#6c87

3

11

    01 f6 ff

        ld bc, -10

#d40a

#6c8a

    Ld40a:

#d40a

#6c8a

3

18

    cd 13 d4

        call Ld413_render_16bit_number_one_digit

#d40d

#6c8d

1

5

    7d

        ld a, l

#d40e

#6c8e

2

8

    c6 30

        add a, 48

#d410

#6c90

3

11

    c3 27 d4

        jp Ld427_draw_character_saving_registers

#d413

#6c93

#d413

#6c93

#d413

#6c93

    ; --------------------------------

#d413

#6c93

    ; - hl: number to draw.

#d413

#6c93

    ; - bc: unit to draw (-10 for tenths, -100 for hundreds, -1000 for thousands, etc.).

#d413

#6c93

    ; - e: filler character to use in the left for the leading zeros.

#d413

#6c93

    Ld413_render_16bit_number_one_digit:

#d413

#6c93

1

5

    af

        xor a

#d414

#6c94

    Ld414_remainder_loop:

#d414

#6c94

1

12

    09

        add hl, bc

#d415

#6c95

1

5

    3c

        inc a

#d416

#6c96

2

13/8

    38 fc

        jr c, Ld414_remainder_loop

#d418

#6c98

2

17

    ed 42

        sbc hl, bc

#d41a

#6c9a

1

5

    3d

        dec a  ; Here, a = hl / (-bc), and hl = hl % (-bc)

#d41b

#6c9b

2

13/8

    20 07

        jr nz, Ld424

#d41d

#6c9d

1

5

    7b

        ld a, e

#d41e

#6c9e

2

8

    fe 20

        cp 32

#d420

#6ca0

3

11

    ca 27 d4

        jp z, Ld427_draw_character_saving_registers

#d423

#6ca3

1

5

    af

        xor a

#d424

#6ca4

    Ld424:

#d424

#6ca4

1

5

    1c

        inc e  ; if the filler character was a space, change it so that the rest of

#d425

#6ca5

               ; empty digits are rendered as zeros.

#d425

#6ca5

2

8

    c6 30

        add a, 48  ; '0'

#d427

#6ca7

    Ld427_draw_character_saving_registers:

#d427

#6ca7

1

5

    d9

        exx

#d428

#6ca8

3

18

    cd b1 d4

            call Ld4b1_draw_character

#d42b

#6cab

1

5

    d9

        exx

#d42c

#6cac

1

11

    c9

        ret

#d42d

#6cad

#d42d

#6cad

#d42d

#6cad

    ; --------------------------------

#d42d

#6cad

    ; Executes some data-defined scripts (pointer of the script is in the stack):

#d42d

#6cad

    ; Script definition:

#d42d

#6cad

    ; - 0: end of script

#d42d

#6cad

    ; - 1: set screen coordinates

#d42d

#6cad

    ; - 2: set attribute

#d42d

#6cad

    ; - 3: next line

#d42d

#6cad

    ; - 4: set scale

#d42d

#6cad

    ; - default: render a character

#d42d

#6cad

    ; input:

#d42d

#6cad

    ; - address of data to use is in the stack

#d42d

#6cad

    Ld42d_execute_ui_script:

#d42d

#6cad

1

5

    d9

        exx

#d42e

#6cae

    Ld42e_loop:

#d42e

#6cae

1

11

    e1

            pop hl

#d42f

#6caf

1

8

    7e

            ld a, (hl)

#d430

#6cb0

1

7

    23

            inc hl

#d431

#6cb1

1

12

    e5

            push hl

#d432

#6cb2

1

5

    b7

            or a

#d433

#6cb3

2

13/8

    28 05

            jr z, Ld43a_done

#d435

#6cb5

3

18

    cd 3c d4

            call Ld43c_execute_one_command

#d438

#6cb8

2

13

    18 f4

            jr Ld42e_loop

#d43a

#6cba

    Ld43a_done:

#d43a

#6cba

1

5

    d9

        exx

#d43b

#6cbb

1

11

    c9

        ret

#d43c

#6cbc

#d43c

#6cbc

#d43c

#6cbc

    ; --------------------------------

#d43c

#6cbc

    Ld43c_execute_one_command:

#d43c

#6cbc

2

8

    fe 01

        cp 1

#d43e

#6cbe

2

13/8

    28 21

        jr z, Ld461_execute_command_1_screen_coordinates

#d440

#6cc0

2

8

    fe 02

        cp 2

#d442

#6cc2

2

13/8

    28 13

        jr z, Ld457_execute_command_2_set_attribute

#d444

#6cc4

2

8

    fe 03

        cp 3

#d446

#6cc6

2

13/8

    28 28

        jr z, Ld470_execute_command_3_next_line

#d448

#6cc8

2

8

    fe 04

        cp 4

#d44a

#6cca

2

13/8

    28 30

        jr z, Ld47c_execute_command_4_set_scale

#d44c

#6ccc

1

5

    4f

        ld c, a

#d44d

#6ccd

3

14

    3a 17 fd

        ld a, (Lfd17_script_scale_x)

#d450

#6cd0

1

5

    b7

        or a

#d451

#6cd1

1

5

    79

        ld a, c

#d452

#6cd2

2

13/8

    28 5d

        jr z, Ld4b1_draw_character

#d454

#6cd4

3

11

    c3 da d4

        jp Ld4b1_draw_character_scaled

#d457

#6cd7

#d457

#6cd7

#d457

#6cd7

    ; --------------------------------

#d457

#6cd7

    Ld457_execute_command_2_set_attribute:

#d457

#6cd7

1

11

    d1

        pop de

#d458

#6cd8

1

11

    e1

        pop hl

#d459

#6cd9

1

8

    7e

            ld a, (hl)

#d45a

#6cda

1

7

    23

            inc hl

#d45b

#6cdb

1

12

    e5

        push hl

#d45c

#6cdc

1

12

    d5

        push de

#d45d

#6cdd

3

14

    32 13 fd

        ld (Lfd13_script_attribute), a

#d460

#6ce0

1

11

    c9

        ret

#d461

#6ce1

#d461

#6ce1

#d461

#6ce1

    ; --------------------------------

#d461

#6ce1

    Ld461_execute_command_1_screen_coordinates:

#d461

#6ce1

1

11

    d1

        pop de

#d462

#6ce2

1

11

    e1

        pop hl

#d463

#6ce3

1

8

    46

            ld b, (hl)

#d464

#6ce4

1

7

    23

            inc hl

#d465

#6ce5

1

8

    4e

            ld c, (hl)

#d466

#6ce6

4

22

    ed 43 31 fd

            ld (Lfd31_script_coordinate), bc

#d46a

#6cea

1

7

    23

            inc hl

#d46b

#6ceb

1

12

    e5

        push hl

#d46c

#6cec

1

12

    d5

        push de

#d46d

#6ced

3

11

    c3 93 d4

        jp Ld493_compute_videomem_ptrs

#d470

#6cf0

#d470

#6cf0

#d470

#6cf0

    ; --------------------------------

#d470

#6cf0

    Ld470_execute_command_3_next_line:

#d470

#6cf0

4

22

    ed 4b 31 fd

        ld bc, (Lfd31_script_coordinate)

#d474

#6cf4

1

5

    04

        inc b

#d475

#6cf5

4

22

    ed 43 31 fd

        ld (Lfd31_script_coordinate), bc

#d479

#6cf9

3

11

    c3 93 d4

        jp Ld493_compute_videomem_ptrs

#d47c

#6cfc

#d47c

#6cfc

#d47c

#6cfc

    ; --------------------------------

#d47c

#6cfc

    ; Reads one byte: yyyyxxxx, and sets the scale to draw characters from

#d47c

#6cfc

    ; each of the two nibbles of that byte:

#d47c

#6cfc

    ; - (Lfd16_script_scale_y) = xxxx

#d47c

#6cfc

    ; - (Lfd16_script_scale_y) = yyyy

#d47c

#6cfc

    ; Input:

#d47c

#6cfc

    ; - in the stack: ptr to read a byte from (will be incremented)

#d47c

#6cfc

    Ld47c_execute_command_4_set_scale:

#d47c

#6cfc

1

11

    d1

        pop de

#d47d

#6cfd

1

11

    e1

        pop hl

#d47e

#6cfe

1

8

    7e

            ld a, (hl)

#d47f

#6cff

1

7

    23

            inc hl

#d480

#6d00

1

12

    e5

        push hl

#d481

#6d01

1

12

    d5

        push de

#d482

#6d02

1

5

    4f

        ld c, a

#d483

#6d03

1

5

    0f

        rrca

#d484

#6d04

1

5

    0f

        rrca

#d485

#6d05

1

5

    0f

        rrca

#d486

#6d06

1

5

    0f

        rrca

#d487

#6d07

2

8

    e6 0f

        and 15

#d489

#6d09

3

14

    32 16 fd

        ld (Lfd16_script_scale_y), a

#d48c

#6d0c

1

5

    79

        ld a, c

#d48d

#6d0d

2

8

    e6 0f

        and 15

#d48f

#6d0f

3

14

    32 17 fd

        ld (Lfd17_script_scale_x), a

#d492

#6d12

1

11

    c9

        ret

#d493

#6d13

#d493

#6d13

#d493

#6d13

    ; --------------------------------

#d493

#6d13

    ; Recalculate pattern table and attribute table pointers

#d493

#6d13

    ; input:

#d493

#6d13

    ; - bc: value of Lfd31_script_coordinate

#d493

#6d13

    ; output:

#d493

#6d13

    ; - Lfd04_script_video_pattern_ptr

#d493

#6d13

    ; - Lfd14_script_video_attribute_ptr

#d493

#6d13

    Ld493_compute_videomem_ptrs:

#d493

#6d13

1

5

    78

        ld a, b

#d494

#6d14

2

8

    e6 f8

        and 248  ; #f8

#d496

#6d16

2

8

    c6 40

        add a, 64

#d498

#6d18

1

5

    67

        ld h, a  ; h = (b & #f8) + 64

#d499

#6d19

1

5

    78

        ld a, b

#d49a

#6d1a

2

8

    e6 07

        and 7

#d49c

#6d1c

1

5

    0f

        rrca

#d49d

#6d1d

1

5

    0f

        rrca

#d49e

#6d1e

1

5

    0f

        rrca

#d49f

#6d1f

1

5

    81

        add a, c

#d4a0

#6d20

1

5

    6f

        ld l, a  ; l = "high 3 bits of b" + c

#d4a1

#6d21

3

17

    22 04 fd

        ld (Lfd04_script_video_pattern_ptr), hl

#d4a4

#6d24

1

5

    7c

        ld a, h

#d4a5

#6d25

1

5

    0f

        rrca

#d4a6

#6d26

1

5

    0f

        rrca

#d4a7

#6d27

1

5

    0f

        rrca

#d4a8

#6d28

2

8

    e6 03

        and 3

#d4aa

#6d2a

2

8

    f6 58

        or 88

#d4ac

#6d2c

1

5

    67

        ld h, a

#d4ad

#6d2d

3

17

    22 14 fd

        ld (Lfd14_script_video_attribute_ptr), hl

#d4b0

#6d30

1

11

    c9

        ret

#d4b1

#6d31

#d4b1

#6d31

#d4b1

#6d31

    ; --------------------------------

#d4b1

#6d31

    ; input:

#d4b1

#6d31

    ; - a: character to draw

#d4b1

#6d31

    ; - (Lfd04_script_video_pattern_ptr) pointer to draw it to in video memory (will be incremented)

#d4b1

#6d31

    ; - (Lfd14_script_video_attribute_ptr) pointer to set the attributes in video memory (will be

#d4b1

#6d31

    ;   incremented).

#d4b1

#6d31

    Ld4b1_draw_character:

#d4b1

#6d31

2

8

    26 00

        ld h, 0

#d4b3

#6d33

1

5

    6f

        ld l, a

#d4b4

#6d34

1

12

    29

        add hl, hl

#d4b5

#6d35

1

12

    29

        add hl, hl

#d4b6

#6d36

1

12

    29

        add hl, hl

#d4b7

#6d37

3

11

    11 80 66

        ld de, L6780_graphic_patterns - 32 * 8  ; there is only data for characters starting at ' ' (32)

#d4ba

#6d3a

1

12

    19

        add hl, de  ; hl = a * 8 + #6680 : get ptr to character to draw

#d4bb

#6d3b

4

22

    ed 5b 04 fd

        ld de, (Lfd04_script_video_pattern_ptr)

#d4bf

#6d3f

1

12

    d5

        push de

#d4c0

#6d40

2

8

    06 08

            ld b, 8

#d4c2

#6d42

    Ld4c2_loop:

#d4c2

#6d42

1

8

    7e

            ld a, (hl)

#d4c3

#6d43

1

8

    12

            ld (de), a

#d4c4

#6d44

1

7

    23

            inc hl

#d4c5

#6d45

1

5

    14

            inc d

#d4c6

#6d46

2

14/9

    10 fa

            djnz Ld4c2_loop

#d4c8

#6d48

1

11

    d1

        pop de

#d4c9

#6d49

1

7

    13

        inc de

#d4ca

#6d4a

4

22

    ed 53 04 fd

        ld (Lfd04_script_video_pattern_ptr), de

#d4ce

#6d4e

3

17

    2a 14 fd

        ld hl, (Lfd14_script_video_attribute_ptr)

#d4d1

#6d51

3

14

    3a 13 fd

        ld a, (Lfd13_script_attribute)

#d4d4

#6d54

1

8

    77

        ld (hl), a

#d4d5

#6d55

1

7

    23

        inc hl

#d4d6

#6d56

3

17

    22 14 fd

        ld (Lfd14_script_video_attribute_ptr), hl

#d4d9

#6d59

1

11

    c9

        ret

#d4da

#6d5a

#d4da

#6d5a

#d4da

#6d5a

    ; --------------------------------

#d4da

#6d5a

    ; input:

#d4da

#6d5a

    ; - a: character to draw

#d4da

#6d5a

    Ld4b1_draw_character_scaled:

#d4da

#6d5a

2

8

    26 00

        ld h, 0

#d4dc

#6d5c

1

5

    6f

        ld l, a

#d4dd

#6d5d

1

12

    29

        add hl, hl

#d4de

#6d5e

1

12

    29

        add hl, hl

#d4df

#6d5f

1

12

    29

        add hl, hl

#d4e0

#6d60

3

11

    11 80 66

        ld de, L6780_graphic_patterns - 32 * 8  ; there is only data for characters starting at ' ' (32)

#d4e3

#6d63

1

12

    19

        add hl, de  ; hl = a * 8 + #6680 : get ptr to character to draw

#d4e4

#6d64

3

14

    3a 17 fd

        ld a, (Lfd17_script_scale_x)

#d4e7

#6d67

2

8

    fe 02

        cp 2

#d4e9

#6d69

2

13/8

    30 17

        jr nc, Ld502

#d4eb

#6d6b

1

5

    eb

        ex de, hl

#d4ec

#6d6c

3

17

    2a 04 fd

        ld hl, (Lfd04_script_video_pattern_ptr)

#d4ef

#6d6f

2

8

    0e 08

        ld c, 8

#d4f1

#6d71

    Ld4f1:

#d4f1

#6d71

3

14

    3a 16 fd

        ld a, (Lfd16_script_scale_y)

#d4f4

#6d74

1

5

    47

        ld b, a

#d4f5

#6d75

    Ld4f5:

#d4f5

#6d75

1

8

    1a

        ld a, (de)

#d4f6

#6d76

1

8

    77

        ld (hl), a

#d4f7

#6d77

3

18

    cd 2a d3

        call Ld32a_inc_video_ptr_y_hl

#d4fa

#6d7a

2

14/9

    10 f9

        djnz Ld4f5

#d4fc

#6d7c

1

7

    13

        inc de

#d4fd

#6d7d

1

5

    0d

        dec c

#d4fe

#6d7e

2

13/8

    20 f1

        jr nz, Ld4f1

#d500

#6d80

2

13

    18 30

        jr Ld532

#d502

#6d82

    Ld502:

#d502

#6d82

2

17

    dd e5

        push ix

#d504

#6d84

1

12

    e5

            push hl

#d505

#6d85

2

16

    dd e1

            pop ix

#d507

#6d87

3

17

    2a 04 fd

            ld hl, (Lfd04_script_video_pattern_ptr)

#d50a

#6d8a

2

8

    0e 08

            ld c, 8

#d50c

#6d8c

    Ld50c:

#d50c

#6d8c

3

21

    dd 7e 00

            ld a, (ix)

#d50f

#6d8f

2

8

    06 08

            ld b, 8

#d511

#6d91

    Ld511:

#d511

#6d91

1

5

    07

            rlca

#d512

#6d92

1

12

    f5

            push af

#d513

#6d93

2

10

    cb 13

                rl e

#d515

#6d95

2

10

    cb 12

                rl d

#d517

#6d97

1

11

    f1

            pop af

#d518

#6d98

2

10

    cb 13

            rl e

#d51a

#6d9a

2

10

    cb 12

            rl d

#d51c

#6d9c

2

14/9

    10 f3

            djnz Ld511

#d51e

#6d9e

3

14

    3a 16 fd

            ld a, (Lfd16_script_scale_y)

#d521

#6da1

1

5

    47

            ld b, a

#d522

#6da2

    Ld522:

#d522

#6da2

1

8

    72

            ld (hl), d

#d523

#6da3

1

5

    2c

            inc l

#d524

#6da4

1

8

    73

            ld (hl), e

#d525

#6da5

1

5

    2d

            dec l

#d526

#6da6

3

18

    cd 2a d3

            call Ld32a_inc_video_ptr_y_hl

#d529

#6da9

2

14/9

    10 f7

            djnz Ld522

#d52b

#6dab

2

12

    dd 23

            inc ix

#d52d

#6dad

1

5

    0d

            dec c

#d52e

#6dae

2

13/8

    20 dc

            jr nz, Ld50c

#d530

#6db0

2

16

    dd e1

        pop ix

#d532

#6db2

    Ld532:

#d532

#6db2

3

17

    2a 04 fd

        ld hl, (Lfd04_script_video_pattern_ptr)

#d535

#6db5

3

14

    3a 17 fd

        ld a, (Lfd17_script_scale_x)

#d538

#6db8

3

18

    cd 51 d3

        call Ld351_add_hl_a

#d53b

#6dbb

3

17

    22 04 fd

        ld (Lfd04_script_video_pattern_ptr), hl

#d53e

#6dbe

3

17

    2a 14 fd

        ld hl, (Lfd14_script_video_attribute_ptr)

#d541

#6dc1

1

12

    e5

        push hl

#d542

#6dc2

4

22

    ed 4b 16 fd

            ld bc, (Lfd16_script_scale_y)

#d546

#6dc6

3

14

    3a 13 fd

            ld a, (Lfd13_script_attribute)

#d549

#6dc9

1

5

    5f

            ld e, a

#d54a

#6dca

    Ld54a:

#d54a

#6dca

1

12

    e5

            push hl

#d54b

#6dcb

1

12

    c5

            push bc

#d54c

#6dcc

    Ld54c:

#d54c

#6dcc

1

8

    73

                ld (hl), e

#d54d

#6dcd

1

7

    23

                inc hl

#d54e

#6dce

2

14/9

    10 fc

                djnz Ld54c

#d550

#6dd0

1

11

    c1

            pop bc

#d551

#6dd1

1

11

    e1

            pop hl

#d552

#6dd2

1

5

    7d

            ld a, l

#d553

#6dd3

2

8

    c6 20

            add a, 32

#d555

#6dd5

1

5

    6f

            ld l, a

#d556

#6dd6

1

5

    7c

            ld a, h

#d557

#6dd7

2

8

    ce 00

            adc a, 0

#d559

#6dd9

1

5

    67

            ld h, a

#d55a

#6dda

1

5

    0d

            dec c

#d55b

#6ddb

2

13/8

    20 ed

            jr nz, Ld54a

#d55d

#6ddd

1

11

    e1

        pop hl

#d55e

#6dde

1

5

    78

        ld a, b

#d55f

#6ddf

3

18

    cd 51 d3

        call Ld351_add_hl_a

#d562

#6de2

3

17

    22 14 fd

        ld (Lfd14_script_video_attribute_ptr), hl

#d565

#6de5

1

11

    c9

        ret

#d566

#6de6

#d566

#6de6

#d566

#6de6

    ; --------------------------------

#d566

#6de6

    ; Interrupt handler routine

#d566

#6de6

    Ld566_interrupt:

#d566

#6de6

1

12

    f5

        push af

#d567

#6de7

1

12

    c5

        push bc

#d568

#6de8

1

12

    d5

        push de

#d569

#6de9

1

12

    e5

        push hl

#d56a

#6dea

            ; Increments the # of interrupts counter (for game timing purposes):

#d56a

#6dea

3

11

    21 34 fd

            ld hl, Lfd34_n_interrupts_this_came_cycle

#d56d

#6ded

1

12

    34

            inc (hl)

#d56e

#6dee

            ; Draw the radar (flickering):

#d56e

#6dee

            ; Player and enemy robots are drawn to view1 and view2 respectively, and in this way, when

#d56e

#6dee

            ; showing them, they show in different colors.

#d56e

#6dee

3

11

    21 00 d8

            ld hl, Ld800_radar_view1

#d571

#6df1

2

8

    0e 4d

            ld c, COLOR_BRIGHT + COLOR_CYAN + PAPER_COLOR_MULTIPLIER * COLOR_BLUE

#d573

#6df3

3

14

    3a 1a fd

            ld a, (Lfd1a_interrupt_parity)

#d576

#6df6

2

8

    ee 01

            xor 1

#d578

#6df8

3

14

    32 1a fd

            ld (Lfd1a_interrupt_parity), a

#d57b

#6dfb

2

13/8

    28 05

            jr z, Ld582_radar_flicker

#d57d

#6dfd

3

11

    21 00 d9

            ld hl, Ld900_radar_view2

#d580

#6e00

2

8

    0e 4e

            ld c, COLOR_BRIGHT + COLOR_YELLOW + PAPER_COLOR_MULTIPLIER * COLOR_BLUE

#d582

#6e02

    Ld582_radar_flicker:

#d582

#6e02

3

18

    cd 9e d5

            call Ld59e_draw_radar

#d585

#6e05

3

14

    3a 53 fd

            ld a, (Lfd53_produce_in_game_sound)

#d588

#6e08

1

5

    b7

            or a

#d589

#6e09

2

13/8

    28 0d

            jr z, Ld598_no_sound

#d58b

#6e0b

1

5

    3c

            inc a

#d58c

#6e0c

2

8

    fe 80

            cp 128

#d58e

#6e0e

2

13/8

    20 01

            jr nz, Ld591_keep_sound

#d590

#6e10

1

5

    af

            xor a

#d591

#6e11

    Ld591_keep_sound:

#d591

#6e11

3

14

    32 53 fd

            ld (Lfd53_produce_in_game_sound), a

#d594

#6e14

1

5

    b7

            or a

#d595

#6e15

3

18/11

    c4 c4 d5

            call nz, Ld5c4_produce_in_game_sound

#d598

#6e18

    Ld598_no_sound:

#d598

#6e18

1

11

    e1

        pop hl

#d599

#6e19

1

11

    d1

        pop de

#d59a

#6e1a

1

11

    c1

        pop bc

#d59b

#6e1b

1

11

    f1

        pop af

#d59c

#6e1c

    Ld59c_empty_interrupt:

#d59c

#6e1c

1

5

    fb

        ei

#d59d

#6e1d

1

11

    c9

        ret

#d59e

#6e1e

#d59e

#6e1e

#d59e

#6e1e

    ; --------------------------------

#d59e

#6e1e

    ; Draws the radar view to video memory

#d59e

#6e1e

    Ld59e_draw_radar:

#d59e

#6e1e

        ; Draw the radar to video memory:

#d59e

#6e1e

1

12

    c5

        push bc

#d59f

#6e1f

2

8

    06 10

            ld b, 16

#d5a1

#6e21

3

11

    11 c6 50

            ld de, L4000_VIDEOMEM_PATTERNS + #10c6  ; pointer to the "radar" view in video memory

#d5a4

#6e24

    Ld5a4_draw_radar_loop_y:

#d5a4

#6e24

1

12

    c5

            push bc

#d5a5

#6e25

1

12

    d5

                push de

#d5a6

#6e26

                    ; Copy a radar row (16 bytes wide)

#d5a6

#6e26

3

11

    01 10 00

                    ld bc, 16

#d5a9

#6e29

2

23/18

    ed b0

                    ldir

#d5ab

#6e2b

1

11

    d1

                pop de

#d5ac

#6e2c

1

5

    eb

                ex de, hl

#d5ad

#6e2d

3

18

    cd 2a d3

                    call Ld32a_inc_video_ptr_y_hl

#d5b0

#6e30

1

5

    eb

                ex de, hl

#d5b1

#6e31

1

11

    c1

            pop bc

#d5b2

#6e32

2

14/9

    10 f0

            djnz Ld5a4_draw_radar_loop_y

#d5b4

#6e34

1

11

    c1

        pop bc

#d5b5

#6e35

        ; Set the attributes:

#d5b5

#6e35

3

11

    21 c6 5a

        ld hl, L5800_VIDEOMEM_ATTRIBUTES + #02c6  ; pointer to the attributes of the radar

#d5b8

#6e38

3

18

    cd bd d5

        call Ld5bd_set_radar_attributes_one_row

#d5bb

#6e3b

2

8

    2e e6

        ld l, #e6  ; second line

#d5bd

#6e3d

    Ld5bd_set_radar_attributes_one_row:

#d5bd

#6e3d

2

8

    06 10

        ld b, 16

#d5bf

#6e3f

    Ld5bf_radar_attributes_loop_x:

#d5bf

#6e3f

1

8

    71

        ld (hl), c

#d5c0

#6e40

1

7

    23

        inc hl

#d5c1

#6e41

2

14/9

    10 fc

        djnz Ld5bf_radar_attributes_loop_x

#d5c3

#6e43

1

11

    c9

        ret

#d5c4

#6e44

#d5c4

#6e44

#d5c4

#6e44

    ; --------------------------------

#d5c4

#6e44

    ; Produces in-game sound based on the value of "a".

#d5c4

#6e44

    ; There are two types of possible sounds:

#d5c4

#6e44

    ; - if a is positive, it'll produce some sound based on reading values from ROM (starting at 0

#d5c4

#6e44

    ;   address).

#d5c4

#6e44

    ; - if a is negative, it produces sound based on the random number generator.

#d5c4

#6e44

    ; Input:

#d5c4

#6e44

    ; - a: type of sound to produce

#d5c4

#6e44

    Ld5c4_produce_in_game_sound:

#d5c4

#6e44

3

11

    fa ec d5

        jp m, Ld5ec_random_noise

#d5c7

#6e47

        ; if "a" is positive, produce a different type of sound:

#d5c7

#6e47

1

5

    47

        ld b, a

#d5c8

#6e48

1

5

    3c

        inc a

#d5c9

#6e49

1

5

    3c

        inc a

#d5ca

#6e4a

3

11

    21 f4 01

        ld hl, 500

#d5cd

#6e4d

1

5

    5f

        ld e, a

#d5ce

#6e4e

2

8

    16 00

        ld d, 0

#d5d0

#6e50

2

8

    0e 00

        ld c, 0

#d5d2

#6e52

1

5

    af

        xor a

#d5d3

#6e53

    Ld5d3:

#d5d3

#6e53

1

5

    0c

        inc c

#d5d4

#6e54

2

17

    ed 52

        sbc hl, de

#d5d6

#6e56

2

13/8

    30 fb

        jr nc, Ld5d3

#d5d8

#6e58

3

11

    21 00 00

        ld hl, 0  ; read values from the ROM at this address (which will be noise, but a different type

#d5db

#6e5b

                  ; of noise).

#d5db

#6e5b

    Ld5db:

#d5db

#6e5b

1

12

    c5

        push bc

#d5dc

#6e5c

1

8

    7e

            ld a, (hl)

#d5dd

#6e5d

1

7

    23

            inc hl

#d5de

#6e5e

2

8

    e6 10

            and 16

#d5e0

#6e60

2

12

    d3 fe

            out (ULA_PORT), a  ; change MIC/EAR state (to produce sound)

#d5e2

#6e62

    Ld5e2:

#d5e2

#6e62

2

14/9

    10 fe

            djnz Ld5e2

#d5e4

#6e64

1

11

    c1

        pop bc

#d5e5

#6e65

1

5

    0d

        dec c

#d5e6

#6e66

2

13/8

    20 f3

        jr nz, Ld5db

#d5e8

#6e68

1

5

    af

        xor a

#d5e9

#6e69

2

12

    d3 fe

        out (ULA_PORT), a  ; change MIC/EAR state (sound off)

#d5eb

#6e6b

1

11

    c9

        ret

#d5ec

#6e6c

#d5ec

#6e6c

#d5ec

#6e6c

    ; --------------------------------

#d5ec

#6e6c

    ; Produce random noise for a short period of time:

#d5ec

#6e6c

    Ld5ec_random_noise:

#d5ec

#6e6c

2

8

    06 1e

        ld b, 30

#d5ee

#6e6e

    Ld5ee_loop:

#d5ee

#6e6e

3

18

    cd 58 d3

        call Ld358_random

#d5f1

#6e71

2

8

    e6 10

        and 16

#d5f3

#6e73

2

12

    d3 fe

        out (ULA_PORT), a  ; change MIC/EAR state (to produce sound)

#d5f5

#6e75

2

14/9

    10 f7

        djnz Ld5ee_loop

#d5f7

#6e77

1

11

    c9

        ret

#d5f8

#6e78

#d5f8

#6e78

#d5f8

#6e78

    ; --------------------------------

#d5f8

#6e78

    ; Updates the two radar buffers (Ld800_radar_view1, Ld800_radar_view2) with all the

#d5f8

#6e78

    ; buildings and robots in the map.

#d5f8

#6e78

    Ld5f8_update_radar_buffers:

#d5f8

#6e78

3

11

    21 00 d8

        ld hl, Ld800_radar_view1

#d5fb

#6e7b

4

22

    ed 5b 1c fd

        ld de, (Lfd1c_radar_scroll_x)

#d5ff

#6e7f

1

5

    7a

        ld a, d

#d600

#6e80

2

8

    c6 dd

        add a, #dd

#d602

#6e82

1

5

    57

        ld d, a  ; de now has the pointer to the map buffer (Ldd00_map) corresponding to the radar view

#d603

#6e83

        ; Updates the contents of the radar:

#d603

#6e83

3

11

    01 10 10

        ld bc, #1010  ; 16, 16

#d606

#6e86

    Ld606_radar_update_loop_y:

#d606

#6e86

1

12

    c5

        push bc

#d607

#6e87

1

12

    d5

        push de

#d608

#6e88

    Ld608_radar_update_loop_x:

#d608

#6e88

1

12

    c5

            push bc

#d609

#6e89

2

8

    06 08

                ld b, 8

#d60b

#6e8b

    Ld60b_radar_update_loop_byte:

#d60b

#6e8b

1

8

    1a

                ld a, (de)

#d60c

#6e8c

1

7

    13

                inc de

#d60d

#6e8d

2

8

    e6 1f

                and #1f

#d60f

#6e8f

2

8

    fe 0f

                cp #0f

#d611

#6e91

1

5

    3f

                ccf  ; carry = 1 if the map has an element > 15 (building)

#d612

#6e92

2

17

    cb 16

                rl (hl)  ; this inserts a 0/1 from the left of the byte. Since we iterate this loop 8

#d614

#6e94

                         ; times, it will eventually replace the old value of this byte in the radar

#d614

#6e94

                         ; buffer.

#d614

#6e94

2

14/9

    10 f5

                djnz Ld60b_radar_update_loop_byte

#d616

#6e96

1

7

    23

                inc hl

#d617

#6e97

1

11

    c1

            pop bc

#d618

#6e98

2

14/9

    10 ee

            djnz Ld608_radar_update_loop_x

#d61a

#6e9a

1

11

    d1

        pop de

#d61b

#6e9b

1

11

    c1

        pop bc

#d61c

#6e9c

        ; increment "y":

#d61c

#6e9c

1

5

    14

        inc d

#d61d

#6e9d

1

5

    14

        inc d

#d61e

#6e9e

1

5

    0d

        dec c

#d61f

#6e9f

2

13/8

    20 e5

        jr nz, Ld606_radar_update_loop_y

#d621

#6ea1

#d621

#6ea1

        ; Sync both radar views:

#d621

#6ea1

3

11

    21 00 d8

        ld hl, Ld800_radar_view1  ; player and player robots will be drawn to view 1

#d624

#6ea4

3

11

    11 00 d9

        ld de, Ld900_radar_view2  ; enemy robots are drawn to view 2

#d627

#6ea7

3

11

    01 00 01

        ld bc, 256

#d62a

#6eaa

2

23/18

    ed b0

        ldir

#d62c

#6eac

#d62c

#6eac

        ; Update robots in the radar view:

#d62c

#6eac

4

16

    fd 21 00 da

        ld iy, Lda00_player1_robots

#d630

#6eb0

2

8

    06 30

        ld b, MAX_ROBOTS_PER_PLAYER * 2

#d632

#6eb2

    Ld632:

#d632

#6eb2

1

12

    c5

        push bc

#d633

#6eb3

3

21

    fd 7e 01

            ld a, (iy + 1)

#d636

#6eb6

1

5

    b7

            or a

#d637

#6eb7

2

13/8

    28 18

            jr z, Ld651_next_robot  ; If there is no robot in this struct, skip

#d639

#6eb9

3

21

    fd 6e 02

            ld l, (iy + ROBOT_STRUCT_X)

#d63c

#6ebc

3

21

    fd 66 03

            ld h, (iy + ROBOT_STRUCT_X + 1)

#d63f

#6ebf

3

21

    fd 4e 04

            ld c, (iy + ROBOT_STRUCT_Y)

#d642

#6ec2

3

21

    fd 7e 0a

            ld a, (iy + ROBOT_STRUCT_CONTROL)

#d645

#6ec5

1

5

    07

            rlca

#d646

#6ec6

2

8

    e6 01

            and 1

#d648

#6ec8

1

5

    47

            ld b, a  ; b = 0 if player robot, and b = 1 if enemy robot.

#d649

#6ec9

3

21

    fd 7e 0a

            ld a, (iy + ROBOT_STRUCT_CONTROL)

#d64c

#6ecc

2

8

    fe 02

            cp 2

#d64e

#6ece

3

18/11

    c4 5a d6

            call nz, Ld65a_flip_2x2_radar_area

#d651

#6ed1

    Ld651_next_robot:

#d651

#6ed1

3

11

    11 10 00

            ld de, ROBOT_STRUCT_SIZE

#d654

#6ed4

2

17

    fd 19

            add iy, de

#d656

#6ed6

1

11

    c1

        pop bc

#d657

#6ed7

2

14/9

    10 d9

        djnz Ld632

#d659

#6ed9

1

11

    c9

        ret

#d65a

#6eda

#d65a

#6eda

#d65a

#6eda

    ; --------------------------------

#d65a

#6eda

    ; Flicker a 2x2 area in the radar view. This function will get the pointer

#d65a

#6eda

    ; in the radar view corresponding to the given coordinates, and then flip

#d65a

#6eda

    ; the bits in a 2x2 area around it.

#d65a

#6eda

    ; Input:

#d65a

#6eda

    ; - hl: x coordinate

#d65a

#6eda

    ; - b: whether to use Ld800_radar_view1 (b == 0), or Ld900_radar_view2 (b == 1)

#d65a

#6eda

    ; - c: y coordinate

#d65a

#6eda

    Ld65a_flip_2x2_radar_area:

#d65a

#6eda

3

18

    cd 7d d6

        call Ld67d_get_radar_view_pointer

#d65d

#6edd

1

5

    4f

        ld c, a

#d65e

#6ede

        ; Flip the first row of 2 bits:

#d65e

#6ede

1

12

    e5

        push hl

#d65f

#6edf

1

8

    7e

            ld a, (hl)

#d660

#6ee0

1

5

    a9

            xor c

#d661

#6ee1

1

8

    77

            ld (hl), a

#d662

#6ee2

2

10

    cb 09

            rrc c

#d664

#6ee4

2

13/8

    30 01

            jr nc, Ld667_not_crossing_to_the_next_byte

#d666

#6ee6

1

7

    23

            inc hl

#d667

#6ee7

    Ld667_not_crossing_to_the_next_byte:

#d667

#6ee7

1

8

    7e

            ld a, (hl)

#d668

#6ee8

1

5

    a9

            xor c

#d669

#6ee9

1

8

    77

            ld (hl), a

#d66a

#6eea

1

11

    e1

        pop hl

#d66b

#6eeb

        ; Flip the next row of 2 bits:

#d66b

#6eeb

1

5

    7d

        ld a, l

#d66c

#6eec

2

8

    d6 10

        sub 16

#d66e

#6eee

1

5

    6f

        ld l, a

#d66f

#6eef

2

10

    cb 01

        rlc c

#d671

#6ef1

1

8

    7e

        ld a, (hl)

#d672

#6ef2

1

5

    a9

        xor c

#d673

#6ef3

1

8

    77

        ld (hl), a

#d674

#6ef4

2

10

    cb 09

        rrc c

#d676

#6ef6

2

13/8

    30 01

        jr nc, Ld679_not_crossing_to_the_next_byte

#d678

#6ef8

1

7

    23

        inc hl

#d679

#6ef9

    Ld679_not_crossing_to_the_next_byte:

#d679

#6ef9

1

8

    7e

        ld a, (hl)

#d67a

#6efa

1

5

    a9

        xor c

#d67b

#6efb

1

8

    77

        ld (hl), a

#d67c

#6efc

1

11

    c9

        ret

#d67d

#6efd

#d67d

#6efd

#d67d

#6efd

    ; --------------------------------

#d67d

#6efd

    ; Get radar view pointer

#d67d

#6efd

    ; input:

#d67d

#6efd

    ; - hl: x coordinate

#d67d

#6efd

    ; - b: whether to use Ld800_radar_view1 (b == 0), or Ld900_radar_view2 (b == 1)

#d67d

#6efd

    ; - c: y coordinate

#d67d

#6efd

    ; output:

#d67d

#6efd

    ; - a: bit (one-hot representation) that corresponds to the given coordinates.

#d67d

#6efd

    ; - hl: byte in the radar view that corresponds to the given coordinates.

#d67d

#6efd

    Ld67d_get_radar_view_pointer:

#d67d

#6efd

4

22

    ed 5b 1c fd

        ld de, (Lfd1c_radar_scroll_x)

#d681

#6f01

1

5

    af

        xor a

#d682

#6f02

2

17

    ed 52

        sbc hl, de

#d684

#6f04

1

5

    7c

        ld a, h

#d685

#6f05

1

5

    b7

        or a

#d686

#6f06

        ; return if when we subtracted "de" from the x coordinate, we don't get a number between 0 and

#d686

#6f06

        ; 127:

#d686

#6f06

2

13/8

    20 1e

        jr nz, Ld6a6_exit

#d688

#6f08

1

5

    7d

        ld a, l

#d689

#6f09

2

8

    fe 7f

        cp 127

#d68b

#6f0b

2

13/8

    30 19

        jr nc, Ld6a6_exit

#d68d

#6f0d

#d68d

#6f0d

        ; here we know that hl - de is on [0,127]

#d68d

#6f0d

2

8

    3e d8

        ld a, Ld800_radar_view1 / 256

#d68f

#6f0f

1

5

    80

        add a, b

#d690

#6f10

1

5

    67

        ld h, a  ; h = b + #d8

#d691

#6f11

1

5

    7d

        ld a, l

#d692

#6f12

2

8

    e6 07

        and #07

#d694

#6f14

1

5

    3c

        inc a

#d695

#6f15

1

5

    47

        ld b, a  ; b = ((hl - de)%8) + 1

#d696

#6f16

1

5

    7d

        ld a, l

#d697

#6f17

1

5

    07

        rlca  ; a = (hl - de)*2  ->  xxxxxxx0

#d698

#6f18

2

8

    e6 f0

        and #f0  ; We keep only the upper 4 bits  ->  xxxx0000

#d69a

#6f1a

1

5

    b1

        or c  ; xxxxyyyy

#d69b

#6f1b

1

5

    07

        rlca

#d69c

#6f1c

1

5

    07

        rlca

#d69d

#6f1d

1

5

    07

        rlca

#d69e

#6f1e

1

5

    07

        rlca

#d69f

#6f1f

1

5

    6f

        ld l, a  ; a = yyyyxxxx. Where yyyy is the y coordinate (in c), and xxxx are bits 3-6 of hl-de

#d6a0

#6f20

1

5

    af

        xor a

#d6a1

#6f21

1

5

    37

        scf

#d6a2

#6f22

    Ld6a2_shift_loop:

#d6a2

#6f22

1

5

    1f

        rra

#d6a3

#6f23

2

14/9

    10 fd

        djnz Ld6a2_shift_loop

#d6a5

#6f25

        ; here "a" is a one-hot representation of (hl - de)%8

#d6a5

#6f25

1

11

    c9

        ret

#d6a6

#6f26

    Ld6a6_exit:

#d6a6

#6f26

1

11

    e1

        pop hl  ; simulate a ret (so, we return from Ld65a_flip_2x2_radar_area, which is the only

#d6a7

#6f27

                ; caller of this function)

#d6a7

#6f27

1

11

    c9

        ret

#d6a8

#6f28

#d6a8

#6f28

#d6a8

#6f28

    ; --------------------------------

#d6a8

#6f28

    Ld6a8_diagonal_pattern1:  ; diagonal line (top-left painted, bottom-left empty)

#d6a8

#6f28

16

        db #ff, #ff, #ff, #fc, #ff, #f0, #ff, #c0, #ff, #00, #fc, #00, #f0, #00, #c0, #00

#d6b8

#6f38

    Ld6b8_diagonal_pattern2:  ; diagonal line (top-left empty, bottom-left painted)

#d6b8

#6f38

16

        db #00, #03, #00, #0f, #00, #3f, #00, #ff, #03, #ff, #0f, #ff, #3f, #ff, #ff, #ff

#d6c8

#6f48

#d6c8

#6f48

#d6c8

#6f48

    ; --------------------------------

#d6c8

#6f48

    Ld6c8_piece_direction_graphic_indices:

#d6c8

#6f48

        ; Index of the graphic to draw for each piece in each of the 4 cardinal directions.

#d6c8

#6f48

        ; For example, notice how "nuclear" has the same graphic regardless of the direction.

#d6c8

#6f48

        ; To find the specific graphic in the "Ld740_isometric_graphic_pointers" table below,

#d6c8

#6f48

        ; multiply the index by 2 (as each graphic is stored twice, one with a precalculated

#d6c8

#6f48

        ; offset of 4 pixels).

#d6c8

#6f48

4

        db 2, 2, 3, 3  ; bipod

#d6cc

#6f4c

4

        db 0, 0, 1, 1  ; tracks

#d6d0

#6f50

4

        db 4, 4, 4, 4  ; antigrav

#d6d4

#6f54

4

        db 5, 6, 7, 8  ; cannon

#d6d8

#6f58

4

        db 9, 9, 10, 10  ; missiles

#d6dc

#6f5c

4

        db 11, 12, 13, 14  ; phasers

#d6e0

#6f60

4

        db 15, 15, 15, 15  ; nuclear

#d6e4

#6f64

4

        db 16, 17, 18, 19  ; electronics

#d6e8

#6f68

#d6e8

#6f68

#d6e8

#6f68

    ; --------------------------------

#d6e8

#6f68

    Ld6e8_additional_isometric_graphic_pointers:  ; 44 pointers

#d6e8

#6f68

2

        dw L8e3a_iso_additional_graphic_0

#d6ea

#6f6a

2

        dw L8f2c_iso_additional_graphic_1

#d6ec

#6f6c

2

        dw L901e_iso_additional_graphic_2

#d6ee

#6f6e

2

        dw L90b0_iso_additional_graphic_3

#d6f0

#6f70

2

        dw L9172_iso_additional_graphic_4

#d6f2

#6f72

2

        dw L9172_iso_additional_graphic_4

#d6f4

#6f74

2

        dw L91f2_iso_additional_graphic_5

#d6f6

#6f76

2

        dw L91f2_iso_additional_graphic_5

#d6f8

#6f78

2

        dw L9278_iso_additional_graphic_6

#d6fa

#6f7a

2

        dw L9278_iso_additional_graphic_6

#d6fc

#6f7c

2

        dw L92f8_iso_additional_graphic_7

#d6fe

#6f7e

2

        dw L92f8_iso_additional_graphic_7

#d700

#6f80

2

        dw L9d9c_iso_additional_graphic_22

#d702

#6f82

2

        dw L9e34_iso_additional_graphic_23

#d704

#6f84

2

        dw L9ef6_iso_additional_graphic_24

#d706

#6f86

2

        dw L9f8e_iso_additional_graphic_25

#d708

#6f88

2

        dw L9372_iso_additional_graphic_8

#d70a

#6f8a

2

        dw L9372_iso_additional_graphic_8

#d70c

#6f8c

2

        dw L940a_iso_additional_graphic_9

#d70e

#6f8e

2

        dw L940a_iso_additional_graphic_9

#d710

#6f90

2

        dw L94a8_iso_additional_graphic_10

#d712

#6f92

2

        dw L94a8_iso_additional_graphic_10

#d714

#6f94

2

        dw L9534_iso_additional_graphic_11

#d716

#6f96

2

        dw L9534_iso_additional_graphic_11

#d718

#6f98

2

        dw L95c6_iso_additional_graphic_12

#d71a

#6f9a

2

        dw L9640_iso_additional_graphic_13

#d71c

#6f9c

2

        dw L96ea_iso_additional_graphic_14

#d71e

#6f9e

2

        dw L9776_iso_additional_graphic_15

#d720

#6fa0

2

        dw L9820_iso_additional_graphic_16

#d722

#6fa2

2

        dw L98ac_iso_additional_graphic_17

#d724

#6fa4

2

        dw L9914_iso_additional_graphic_18

#d726

#6fa6

2

        dw L9a16_iso_additional_graphic_19

#d728

#6fa8

2

        dw L9b18_iso_additional_graphic_20

#d72a

#6faa

2

        dw L9c5a_iso_additional_graphic_21

#d72c

#6fac

2

        dw La0e2_iso_additional_graphic_27

#d72e

#6fae

2

        dw La1e4_iso_additional_graphic_28

#d730

#6fb0

2

        dw La2e6_iso_additional_graphic_29

#d732

#6fb2

2

        dw La428_iso_additional_graphic_30

#d734

#6fb4

2

        dw L8e3a_iso_additional_graphic_0

#d736

#6fb6

2

        dw L8e3a_iso_additional_graphic_0

#d738

#6fb8

2

        dw L8e3a_iso_additional_graphic_0

#d73a

#6fba

2

        dw L8e3a_iso_additional_graphic_0

#d73c

#6fbc

2

        dw La050_iso_additional_graphic_26

#d73e

#6fbe

2

        dw La050_iso_additional_graphic_26

#d740

#6fc0

#d740

#6fc0

    Ld740_isometric_graphic_pointers:  ; 58 pointers

#d740

#6fc0

2

        dw L6980_iso_graphic_0  ; tracks

#d742

#6fc2

2

        dw L6a24_iso_graphic_1

#d744

#6fc4

2

        dw L6afe_iso_graphic_2

#d746

#6fc6

2

        dw L6ba8_iso_graphic_3

#d748

#6fc8

2

        dw L6c8a_iso_graphic_4  ; bipod

#d74a

#6fca

2

        dw L6d40_iso_graphic_5

#d74c

#6fcc

2

        dw L6e32_iso_graphic_6

#d74e

#6fce

2

        dw L6ee2_iso_graphic_7

#d750

#6fd0

2

        dw L6fcc_iso_graphic_8  ; antigrav

#d752

#6fd2

2

        dw L7058_iso_graphic_9

#d754

#6fd4

2

        dw L7112_iso_graphic_10  ; cannon

#d756

#6fd6

2

        dw L71bc_iso_graphic_11

#d758

#6fd8

2

        dw L729e_iso_graphic_12

#d75a

#6fda

2

        dw L7354_iso_graphic_13

#d75c

#6fdc

2

        dw L7446_iso_graphic_14

#d75e

#6fde

2

        dw L74fc_iso_graphic_15

#d760

#6fe0

2

        dw L75ee_iso_graphic_16

#d762

#6fe2

2

        dw L7686_iso_graphic_17

#d764

#6fe4

2

        dw L7750_iso_graphic_18  ; missiles

#d766

#6fe6

2

        dw L77f4_iso_graphic_19

#d768

#6fe8

2

        dw L78ce_iso_graphic_20

#d76a

#6fea

2

        dw L7978_iso_graphic_21

#d76c

#6fec

2

        dw L7a5a_iso_graphic_22  ; phaser

#d76e

#6fee

2

        dw L7b04_iso_graphic_23

#d770

#6ff0

2

        dw L7be6_iso_graphic_24

#d772

#6ff2

2

        dw L7c96_iso_graphic_25

#d774

#6ff4

2

        dw L7d80_iso_graphic_26

#d776

#6ff6

2

        dw L7e30_iso_graphic_27

#d778

#6ff8

2

        dw L7f1a_iso_graphic_28

#d77a

#6ffa

2

        dw L7fb8_iso_graphic_29

#d77c

#6ffc

2

        dw L808a_iso_graphic_30  ; nuclear

#d77e

#6ffe

2

        dw L813a_iso_graphic_31

#d780

#7000

2

        dw L8224_iso_graphic_32

#d782

#7002

2

        dw L82b6_iso_graphic_33

#d784

#7004

2

        dw L8348_iso_graphic_34

#d786

#7006

2

        dw L83da_iso_graphic_35

#d788

#7008

2

        dw L846c_iso_graphic_36

#d78a

#700a

2

        dw L84fe_iso_graphic_37

#d78c

#700c

2

        dw L8590_iso_graphic_38

#d78e

#700e

2

        dw L8622_iso_graphic_39

#d790

#7010

2

        dw L86b4_iso_graphic_40

#d792

#7012

2

        dw L86f8_iso_graphic_41

#d794

#7014

2

        dw L8752_iso_graphic_42

#d796

#7016

2

        dw L8796_iso_graphic_43

#d798

#7018

2

        dw L87f0_iso_graphic_44

#d79a

#701a

2

        dw L8858_iso_graphic_45

#d79c

#701c

2

        dw L88e2_iso_graphic_46

#d79e

#701e

2

        dw L8924_iso_graphic_47

#d7a0

#7020

2

        dw L8966_iso_graphic_48

#d7a2

#7022

2

        dw L89b6_iso_graphic_49

#d7a4

#7024

2

        dw L8a06_iso_graphic_50

#d7a6

#7026

2

        dw L8a8c_iso_graphic_51

#d7a8

#7028

2

        dw L8b3e_iso_graphic_52

#d7aa

#702a

2

        dw L8bc4_iso_graphic_53

#d7ac

#702c

2

        dw L8c76_iso_graphic_54

#d7ae

#702e

2

        dw L8cde_iso_graphic_55

#d7b0

#7030

2

        dw L8d46_iso_graphic_56

#d7b2

#7032

2

        dw L8dc0_iso_graphic_57

#d7b4

#7034

#d7b4

#7034

#d7b4

#7034

    ; --------------------------------

#d7b4

#7034

    Ld7b4_piece_heights:

#d7b4

#7034

1

        db 11  ; bipod

#d7b5

#7035

1

        db 7  ; tracks

#d7b6

#7036

1

        db 8  ; antigrav

#d7b7

#7037

1

        db 6  ; cannon

#d7b8

#7038

1

        db 6  ; missiles

#d7b9

#7039

1

        db 7  ; phasers

#d7ba

#703a

1

        db 7  ; nuclear

#d7bb

#703b

1

        db 7  ; electronics

#d7bc

#703c

#d7bc

#703c

    Ld7bc_map_piece_heights:  ; 23 elements

#d7bc

#703c

16

        db #00, #00, #02, #02, #02, #02, #03, #03, #06, #06, #06, #06, #00, #00, #00, #07

#d7cc

#704c

7

        db #0f, #07, #0f, #00, #00, #63, #00

#d7d3

#7053

#d7d3

#7053

#d7d3

#7053

    ; --------------------------------

#d7d3

#7053

    ; RAM Variables:

#d7d3

#7053

    Ld7d3_bullets: equ #d7d3  ; 5 * 9 bytes

#d7d3

#7053

    Ld800_radar_view1: equ #d800  ; 256 bytes. Player and player robots are drawn here

#d7d3

#7053

    Ld900_radar_view2: equ #d900  ; 256 bytes. Enemy robots are drawn here

#d7d3

#7053

#d7d3

#7053

#d7d3

#7053

    ; When saving a game, RAM is stored starting from here:

#d7d3

#7053

    Ld92b_save_game_start: equ #d92b  ; 213 bytes, buffer where a few things are copied before saving a

#d7d3

#7053

                                      ; game: bullet state (45 bytes), and 168 bytes from

#d7d3

#7053

                                      ; Lff01_building_decorations.

#d7d3

#7053

    Lda00_player1_robots: equ #da00  ; 384 bytes  (24 robots * 16 bytes per robot)

#d7d3

#7053

    Ldb80_player2_robots: equ #db80  ; 384 bytes  (24 robots * 16 bytes per robot)

#d7d3

#7053

#d7d3

#7053

    ; Each byte of the map is organized as:

#d7d3

#7053

    ; - dcbaaaaa:

#d7d3

#7053

    ;     - aaaaa: element type

#d7d3

#7053

    ;     - b: as elements use a 2x2 position, only the bottom-left corner has this as 0

#d7d3

#7053

    ;     - c: indicates a robot/factory/warbase is here

#d7d3

#7053

    ;     - d: indicates player is here

#d7d3

#7053

    Ldd00_map: equ #dd00  ; map: 512*16 = 8192 bytes

#d7d3

#7053

#d7d3

#7053

    Lfd00_random_seed: equ #fd00  ; 4 bytes

#d7d3

#7053

    Lfd04_script_video_pattern_ptr: equ #fd04  ; 2 bytes

#d7d3

#7053

    Lfd06_scroll_ptr: equ #fd06  ; 2 bytes

#d7d3

#7053

    Lfd08_stack_ptr_buffer: equ #fd08  ; 2 bytes

#d7d3

#7053

    Lfd0a_scroll_x: equ #fd0a  ; 2 bytes

#d7d3

#7053

    Lfd0c_keyboard_state: equ #fd0c  ; 1 byte

#d7d3

#7053

    Lfd0d_player_y: equ #fd0d  ; 1 byte. Narrow axis of the map.

#d7d3

#7053

    Lfd0e_player_x: equ #fd0e  ; 2 bytes. Long axis of the map

#d7d3

#7053

    Lfd10_player_altitude: equ #fd10  ; 1 byte.

#d7d3

#7053

    Lfd11_player_iso_coordinates_if_deferred: equ #fd11  ; 2 bytes. If rendering of the player is

#d7d3

#7053

                                                         ; sprite is deferred due to an overlapping

#d7d3

#7053

                                                         ; sprite, this will contain the original

#d7d3

#7053

                                                         ; isometric coordinates of the player sprite.

#d7d3

#7053

    Lfd13_script_attribute: equ #fd13  ; 1 byte

#d7d3

#7053

    Lfd14_script_video_attribute_ptr: equ #fd14  ; 2 bytes

#d7d3

#7053

    Lfd16_script_scale_y: equ #fd16  ; 1 byte

#d7d3

#7053

    Lfd17_script_scale_x: equ #fd17  ; 1 byte

#d7d3

#7053

    ; 2 unused bytes

#d7d3

#7053

    Lfd1a_interrupt_parity: equ #fd1a  ; 1 byte. Used to determine if we are in an even or odd

#d7d3

#7053

                                       ; interrupt call.

#d7d3

#7053

    Lfd1b_radar_scroll_x_tile: equ #fd1b  ; 1 byte. Same as the variable below, but at tile resolution.

#d7d3

#7053

    Lfd1c_radar_scroll_x: equ #fd1c  ; 2 bytes

#d7d3

#7053

    Lfd1e_player_visible_in_radar: equ #fd1e  ; 1 byte. The least-significant bit of this variable

#d7d3

#7053

                                              ; represents whether to draw the player in the radar or

#d7d3

#7053

                                              ; not. It's used to make the player blink.

#d7d3

#7053

    Lfd1f_cursor_position: equ #fd1f  ; 2 bytes: x, y

#d7d3

#7053

    Lfd21_construction_selected_pieces: equ #fd21  ; 1 byte

#d7d3

#7053

    Lfd22_player1_resource_counts: equ #fd22  ; 7 bytes

#d7d3

#7053

    Lfd29_resource_counts_buffer: equ #fd29  ; 7 bytes. Used, for example, in the robot construction

#d7d3

#7053

                                             ; screen, to keep track of resources left after the

#d7d3

#7053

                                             ; selected pieces are discounted from the resources.

#d7d3

#7053

    Lfd30_player_elevate_timer: equ #fd30  ; 1 byte. If this is > 0, player ship elevates

#d7d3

#7053

                                           ; automatically, until this reaches 0 (used when exiting a

#d7d3

#7053

                                           ; robot / warbase, for example).

#d7d3

#7053

    Lfd31_script_coordinate: equ #fd31  ; 2 bytes

#d7d3

#7053

    Lfd33_title_color: equ #fd33  ; 1 byte. Used only in the title screen to do title color rotation.

#d7d3

#7053

    Lfd34_n_interrupts_this_came_cycle: equ #fd34  ; 1 byte

#d7d3

#7053

    Lfd35_minutes: equ #fd35  ; 1 byte

#d7d3

#7053

    Lfd36_hours: equ #fd36  ; 1 byte

#d7d3

#7053

    Lfd37_days: equ #fd37  ; 2 bytes

#d7d3

#7053

    Lfd39_current_in_game_right_hud: equ #fd39  ; 1 byte. Stores which is the info/menu to display in

#d7d3

#7053

                                                ; the right hud.

#d7d3

#7053

    Lfd3a_player1_base_factory_counts: equ #fd3a  ; 7 bytes

#d7d3

#7053

    Lfd41_player1_robot_count: equ #fd41  ; 1 byte

#d7d3

#7053

    Lfd42_player2_base_factory_counts: equ #fd42  ; 7 bytes

#d7d3

#7053

    Lfd49_player2_robot_count: equ #fd49  ; 1 byte

#d7d3

#7053

    Lfd4a_player2_resource_counts: equ #fd4a  ; 7 bytes

#d7d3

#7053

    Lfd51_current_robot_player_or_enemy: equ #fd51  ; 1 byte. Used to indicate if the robot we are

#d7d3

#7053

                                                    ; working with is controlled by the player or the

#d7d3

#7053

                                                    ; enemy AI. (0: player, 1: enemy AI).

#d7d3

#7053

    Lfd52_update_radar_buffer_signal: equ #fd52  ; 1 byte. If this is set to 1, the radar buffer will

#d7d3

#7053

                                                 ; be updated this cycle.

#d7d3

#7053

    Lfd53_produce_in_game_sound: equ #fd53  ; 1 byte. When != 0, it will make the game interrupt

#d7d3

#7053

                                            ; produce some sound, incrementing once per cycle until

#d7d3

#7053

                                            ; reaching 128 or 0, at which point the sound it will stop.

#d7d3

#7053

    Lfd54_music_channel1_ret_address: equ #fd54  ; 2 bytes

#d7d3

#7053

    Lfd56_music_channel2_ret_address: equ #fd56  ; 2 bytes

#d7d3

#7053

    ; 24 unused bytes

#d7d3

#7053

    Lfd70_warbases: equ #fd70

#d7d3

#7053

    Lfd84_factories: equ Lfd70_warbases + N_WARBASES * BUILDING_STRUCT_SIZE

#d7d3

#7053

    Lfdfc_save_game_end: equ #fdfc  ; When saving a game, RAM is stored up to here.

#d7d3

#7053

#d7d3

#7053

#d7d3

#7053

    Lfdfd_interrupt_jp: equ #fdfd  ; 1 byte

#d7d3

#7053

    Lfdfe_interrupt_pointer: equ #fdfe  ; 2 bytes

#d7d3

#7053

    Lfe00_interrupt_vector_table: equ #fe00  ; 257 bytes

#d7d3

#7053

    Lff01_building_decorations: equ #ff01  ; 56 structs of 3 bytes each: map ptr (2 bytes), type (1

#d7d3

#7053

                                           ; byte)

#d7d3

#7053

Source Code file: netherearth-annotated-data.asm

Address | Position in Binary | Size | Timing | Assembled | Code

#6780

#0000

    L6780_graphic_patterns:

#6780

#0000

        ; Each block of 8 bytes correspods to a character. So, this includes

#6780

#0000

        ; a definition of the font being used, the first character is ' ':

#6780

#0000

        ; these tags inside comments are used to visualize the gfx using MDL with the "-mdl-asm+:html" flag.

#6780

#0000

8

        db #00, #00, #00, #00, #00, #00, #00, #00  ;

#6788

#0008

8

        db #00, #18, #18, #18, #18, #00, #18, #00  ;

#6790

#0010

8

        db #00, #36, #6c, #00, #00, #00, #00, #00  ;

#6798

#0018

8

        db #00, #24, #7e, #24, #24, #7e, #24, #00  ;

#67a0

#0020

8

        db #18, #3e, #78, #3c, #1e, #1e, #7c, #18  ;

#67a8

#0028

8

        db #00, #00, #66, #4c, #18, #32, #66, #00  ;

#67b0

#0030

8

        db #38, #44, #4c, #38, #6e, #46, #3b, #00  ;

#67b8

#0038

8

        db #00, #18, #30, #00, #00, #00, #00, #00  ;

#67c0

#0040

8

        db #04, #0c, #18, #18, #18, #18, #0c, #04  ;

#67c8

#0048

8

        db #20, #30, #18, #18, #18, #18, #30, #20  ;

#67d0

#0050

8

        db #00, #00, #14, #08, #3e, #08, #14, #00  ;

#67d8

#0058

8

        db #00, #00, #08, #08, #3e, #08, #08, #00  ;

#67e0

#0060

8

        db #00, #00, #00, #00, #0c, #0c, #0c, #08  ;

#67e8

#0068

8

        db #00, #00, #00, #00, #3e, #00, #00, #00  ;

#67f0

#0070

8

        db #00, #00, #00, #00, #00, #18, #18, #00  ;

#67f8

#0078

8

        db #00, #00, #06, #0c, #18, #30, #60, #00  ;

#6800

#0080

8

        db #36, #77, #67, #6b, #73, #77, #36, #00  ;

#6808

#0088

8

        db #0c, #3c, #1c, #1c, #1c, #1c, #1c, #00  ;

#6810

#0090

8

        db #3c, #76, #36, #04, #08, #7e, #7e, #00  ;

#6818

#0098

8

        db #34, #76, #06, #04, #26, #76, #34, #00  ;

#6820

#00a0

8

        db #17, #17, #37, #77, #77, #07, #07, #00  ;

#6828

#00a8

8

        db #7f, #70, #66, #07, #37, #77, #36, #00  ;

#6830

#00b0

8

        db #16, #36, #70, #74, #76, #76, #34, #00  ;

#6838

#00b8

8

        db #7e, #7e, #02, #0c, #1c, #38, #78, #00  ;

#6840

#00c0

8

        db #36, #77, #77, #36, #77, #77, #36, #00  ;

#6848

#00c8

8

        db #36, #77, #77, #37, #07, #76, #34, #00  ;

#6850

#00d0

8

        db #00, #00, #18, #18, #00, #18, #18, #00  ;

#6858

#00d8

8

        db #00, #00, #18, #18, #00, #18, #18, #10  ;

#6860

#00e0

8

        db #00, #08, #18, #30, #60, #30, #18, #08  ;

#6868

#00e8

8

        db #00, #00, #00, #3e, #00, #3e, #00, #00  ;

#6870

#00f0

8

        db #00, #20, #30, #18, #0c, #18, #30, #20  ;

#6878

#00f8

8

        db #2c, #6e, #6e, #0c, #00, #0c, #0c, #00  ;

#6880

#0100

8

        db #3e, #59, #45, #5d, #55, #5d, #3e, #00  ;

#6888

#0108

8

        db #3e, #77, #77, #77, #7f, #77, #77, #00  ;

#6890

#0110

8

        db #76, #77, #76, #74, #76, #77, #76, #00  ;

#6898

#0118

8

        db #17, #33, #71, #70, #71, #33, #17, #00  ;

#68a0

#0120

8

        db #74, #76, #77, #77, #77, #76, #74, #00  ;

#68a8

#0128

8

        db #77, #71, #70, #76, #70, #71, #77, #00  ;

#68b0

#0130

8

        db #77, #71, #70, #76, #70, #70, #70, #00  ;

#68b8

#0138

8

        db #17, #33, #71, #70, #77, #37, #16, #00  ;

#68c0

#0140

8

        db #77, #77, #77, #7f, #77, #77, #77, #00  ;

#68c8

#0148

8

        db #1c, #1c, #1c, #1c, #1c, #1c, #1c, #00  ;

#68d0

#0150

8

        db #07, #07, #07, #07, #37, #77, #36, #00  ;

#68d8

#0158

8

        db #77, #76, #74, #70, #74, #76, #77, #00  ;

#68e0

#0160

8

        db #70, #70, #70, #70, #71, #73, #77, #00  ;

#68e8

#0168

8

        db #63, #77, #7f, #7f, #77, #77, #77, #00  ;

#68f0

#0170

8

        db #67, #77, #7f, #7f, #7f, #77, #73, #00  ;

#68f8

#0178

8

        db #36, #77, #77, #77, #77, #77, #36, #00  ;

#6900

#0180

8

        db #74, #76, #76, #76, #74, #70, #70, #00  ;

#6908

#0188

8

        db #36, #77, #77, #77, #77, #7e, #37, #00  ;

#6910

#0190

8

        db #74, #76, #76, #76, #74, #76, #77, #00  ;

#6918

#0198

8

        db #37, #79, #7c, #3e, #1f, #4f, #76, #00  ;

#6920

#01a0

8

        db #7f, #5d, #5d, #1c, #1c, #1c, #1c, #00  ;

#6928

#01a8

8

        db #77, #77, #77, #77, #77, #77, #36, #00  ;

#6930

#01b0

8

        db #63, #63, #63, #63, #77, #3e, #1c, #00  ;

#6938

#01b8

8

        db #6b, #6b, #6b, #6b, #77, #7f, #36, #00  ;

#6940

#01c0

8

        db #77, #77, #36, #14, #36, #77, #77, #00  ;

#6948

#01c8

8

        db #77, #77, #36, #3e, #1c, #1c, #1c, #00  ;

#6950

#01d0

8

        db #77, #4f, #1f, #3e, #7c, #79, #77, #00  ;

#6958

#01d8

8

        db #00, #0e, #0c, #0c, #0c, #0c, #0e, #00  ;

#6960

#01e0

8

        db #00, #00, #60, #30, #18, #0c, #06, #00  ;

#6968

#01e8

8

        db #00, #70, #10, #10, #10, #10, #70, #00  ;

#6970

#01f0

8

        db #00, #10, #38, #54, #10, #10, #10, #00  ;

#6978

#01f8

8

        db #00, #00, #00, #00, #00, #00, #00, #ff  ;

#6980

#0200

#6980

#0200

    L6980_isometric_graphics:

#6980

#0200

        ; These are definitions of the different isometric pieces (bipod, cannon, etc.)

#6980

#0200

        ; The first two bytes of each graphic are:

#6980

#0200

        ; - height (in pixels)

#6980

#0200

        ; - width (in bytes)

#6980

#0200

        ; The rest of the data shuold be height*width*2 bytes, where each pair of bytes

#6980

#0200

        ; represents 8 pixels. The first is the "and mask", and the second the "or" mask, as

#6980

#0200

        ; usual in ZX Spectrum graphics.

#6980

#0200

        ; Graphics are stored upside down, since the game renders them starting at the bottom.

#6980

#0200

    L6980_iso_graphic_0:  ;

#6980

#0200

16

        db #1b, #03, #ff, #00, #7f, #80, #ff, #00, #fe, #01, #1f, #e0, #ff, #00, #fc, #02

#6990

#0210

16

        db #07, #f8, #ff, #00, #fc, #02, #01, #be, #ff, #00, #f8, #05, #00, #9f, #7f, #80

#69a0

#0220

16

        db #f8, #04, #00, #fb, #1f, #e0, #f8, #06, #00, #79, #07, #f8, #f8, #04, #00, #9f

#69b0

#0230

16

        db #01, #be, #f8, #04, #00, #a7, #00, #9f, #fc, #03, #00, #29, #00, #fb, #ef, #10

#69c0

#0240

16

        db #00, #ca, #00, #79, #c3, #3c, #c0, #32, #00, #9f, #80, #5f, #f0, #0c, #00, #a7

#69d0

#0250

16

        db #80, #57, #3c, #c3, #00, #29, #00, #b3, #0f, #f0, #01, #ca, #00, #9f, #03, #7c

#69e0

#0260

16

        db #c1, #32, #00, #cf, #00, #3f, #f3, #0c, #00, #93, #00, #f7, #3f, #c0, #00, #94

#69f0

#0270

16

        db #00, #f3, #1f, #e0, #80, #65, #00, #3f, #1f, #60, #e0, #19, #00, #4f, #1f, #20

#6a00

#0280

16

        db #f8, #06, #00, #53, #1f, #e0, #fe, #01, #00, #94, #1f, #e0, #ff, #00, #80, #65

#6a10

#0290

16

        db #1f, #20, #ff, #00, #e0, #19, #3f, #40, #ff, #00, #f8, #06, #3f, #40, #ff, #00

#6a20

#02a0

4

        db #fe, #01, #7f, #80

#6a24

#02a4

    L6a24_iso_graphic_1:  ;

#6a24

#02a4

16

        db #1b, #04, #ff, #00, #f7, #08, #ff, #00, #ff, #00, #ff, #00, #e1, #1e, #ff, #00

#6a34

#02b4

16

        db #ff, #00, #ff, #00, #c0, #2f, #7f, #80, #ff, #00, #ff, #00, #c0, #2b, #1f, #e0

#6a44

#02c4

16

        db #ff, #00, #ff, #00, #80, #59, #07, #f8, #ff, #00, #ff, #00, #80, #4f, #01, #be

#6a54

#02d4

16

        db #ff, #00, #ff, #00, #80, #67, #00, #9f, #7f, #80, #ff, #00, #80, #49, #00, #fb

#6a64

#02e4

16

        db #1f, #e0, #ff, #00, #80, #4a, #00, #79, #0f, #f0, #ff, #00, #c0, #32, #00, #9f

#6a74

#02f4

16

        db #0f, #b0, #fe, #01, #f0, #0c, #00, #a7, #0f, #90, #fc, #03, #3c, #c3, #00, #29

#6a84

#0304

16

        db #0f, #f0, #f8, #05, #0f, #f0, #00, #ca, #0f, #70, #f8, #05, #03, #7c, #c0, #32

#6a94

#0314

16

        db #0f, #90, #f0, #0b, #00, #3f, #f0, #0c, #1f, #a0, #f0, #09, #00, #f7, #3c, #c3

#6aa4

#0324

16

        db #1f, #20, #f0, #0c, #00, #f3, #0f, #f0, #3f, #c0, #f0, #09, #00, #3f, #03, #7c

#6ab4

#0334

16

        db #ff, #00, #f0, #09, #00, #4f, #01, #3e, #ff, #00, #f8, #06, #00, #53, #01, #f6

#6ac4

#0344

16

        db #ff, #00, #fe, #01, #00, #94, #01, #f2, #ff, #00, #ff, #00, #80, #65, #01, #3e

#6ad4

#0354

16

        db #ff, #00, #ff, #00, #e0, #19, #01, #4e, #ff, #00, #ff, #00, #f8, #06, #01, #52

#6ae4

#0364

16

        db #ff, #00, #ff, #00, #fe, #01, #03, #94, #ff, #00, #ff, #00, #ff, #00, #83, #64

#6af4

#0374

10

        db #ff, #00, #ff, #00, #ff, #00, #e7, #18, #ff, #00

#6afe

#037e

    L6afe_iso_graphic_2:  ;

#6afe

#037e

16

        db #1c, #03, #ff, #00, #3f, #c0, #ff, #00, #fe, #01, #0f, #b0, #ff, #00, #fe, #01

#6b0e

#038e

16

        db #03, #cc, #ff, #00, #fc, #02, #03, #b4, #ff, #00, #fc, #02, #03, #cc, #ff, #00

#6b1e

#039e

16

        db #f8, #07, #03, #34, #cf, #30, #f8, #07, #03, #8c, #83, #6c, #f0, #0a, #03, #64

#6b2e

#03ae

16

        db #80, #73, #f0, #0b, #07, #18, #00, #ad, #e0, #1c, #07, #c8, #00, #b3, #e0, #1e

#6b3e

#03be

16

        db #0e, #31, #00, #cd, #c0, #29, #0e, #91, #00, #e3, #c0, #2c, #1c, #62, #00, #99

#6b4e

#03ce

16

        db #80, #73, #1c, #22, #01, #c6, #80, #78, #38, #c7, #01, #32, #00, #a6, #38, #47

#6b5e

#03de

16

        db #03, #8c, #00, #b1, #70, #8a, #03, #64, #00, #cc, #70, #8b, #07, #18, #00, #e3

#6b6e

#03ee

16

        db #e0, #1c, #07, #c8, #00, #99, #e0, #1e, #0f, #30, #01, #c6, #c0, #29, #0f, #90

#6b7e

#03fe

16

        db #c1, #32, #c0, #2c, #1f, #60, #f3, #0c, #c0, #33, #1f, #20, #ff, #00, #c0, #38

#6b8e

#040e

16

        db #3f, #c0, #ff, #00, #c0, #26, #3f, #40, #ff, #00, #c0, #31, #7f, #80, #ff, #00

#6b9e

#041e

10

        db #f0, #0c, #7f, #80, #ff, #00, #fc, #03, #ff, #00

#6ba8

#0428

    L6ba8_iso_graphic_3:  ;

#6ba8

#0428

16

        db #1c, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #e0, #1b, #ff, #00

#6bb8

#0438

16

        db #ff, #00, #ff, #00, #e0, #1c, #3f, #c0, #ff, #00, #ff, #00, #c0, #2b, #3f, #40

#6bc8

#0448

16

        db #ff, #00, #ff, #00, #c0, #2c, #3f, #c0, #ff, #00, #ff, #00, #80, #73, #3c, #43

#6bd8

#0458

16

        db #ff, #00, #ff, #00, #80, #78, #38, #c6, #3f, #c0, #ff, #00, #00, #a6, #38, #47

#6be8

#0468

16

        db #0f, #30, #ff, #00, #00, #b1, #70, #8a, #0f, #d0, #fe, #01, #00, #cc, #70, #8b

#6bf8

#0478

16

        db #0f, #30, #fe, #01, #00, #e3, #e0, #1c, #0f, #d0, #fc, #02, #00, #99, #e0, #1e

#6c08

#0488

16

        db #0f, #30, #fc, #02, #01, #c6, #c0, #29, #0f, #90, #f8, #07, #01, #32, #c0, #2c

#6c18

#0498

16

        db #1f, #60, #f8, #07, #03, #8c, #80, #73, #1f, #20, #f0, #0a, #03, #64, #80, #78

#6c28

#04a8

16

        db #3f, #c0, #f0, #0b, #07, #18, #00, #a6, #3f, #40, #f0, #0c, #07, #c8, #00, #b1

#6c38

#04b8

16

        db #7f, #80, #f0, #0e, #0e, #31, #00, #cc, #7f, #80, #f0, #09, #0e, #91, #00, #e3

#6c48

#04c8

16

        db #ff, #00, #f0, #0c, #1c, #62, #00, #99, #ff, #00, #fc, #03, #1c, #22, #01, #c6

#6c58

#04d8

16

        db #ff, #00, #ff, #00, #3c, #c3, #01, #32, #ff, #00, #ff, #00, #fc, #03, #03, #8c

#6c68

#04e8

16

        db #ff, #00, #ff, #00, #fc, #02, #03, #64, #ff, #00, #ff, #00, #fc, #03, #07, #18

#6c78

#04f8

16

        db #ff, #00, #ff, #00, #ff, #00, #07, #c8, #ff, #00, #ff, #00, #ff, #00, #cf, #30

#6c88

#0508

2

        db #ff, #00

#6c8a

#050a

    L6c8a_iso_graphic_4:  ;

#6c8a

#050a

16

        db #1e, #03, #ff, #00, #ff, #00, #ff, #00, #fe, #01, #7f, #80, #ff, #00, #fe, #01

#6c9a

#051a

16

        db #1f, #60, #ff, #00, #fc, #03, #07, #58, #ff, #00, #fc, #03, #01, #56, #ff, #00

#6caa

#052a

16

        db #f8, #07, #00, #d5, #7f, #80, #f8, #06, #00, #55, #1f, #60, #f8, #06, #00, #35

#6cba

#053a

16

        db #07, #58, #f8, #04, #00, #15, #03, #54, #e0, #1e, #00, #0d, #03, #54, #e0, #17

#6cca

#054a

16

        db #00, #1d, #03, #54, #c0, #35, #00, #98, #03, #fc, #c0, #35, #00, #78, #03, #84

#6cda

#055a

16

        db #80, #7d, #00, #78, #07, #88, #80, #65, #00, #78, #07, #88, #80, #63, #00, #7c

#6cea

#056a

16

        db #0f, #f0, #80, #41, #00, #73, #7f, #80, #80, #60, #00, #f0, #3f, #c0, #e0, #11

#6cfa

#057a

16

        db #00, #a1, #3f, #40, #f0, #09, #00, #b1, #3f, #c0, #f8, #07, #00, #8f, #3f, #40

#6d0a

#058a

16

        db #fc, #03, #00, #8a, #7f, #80, #fc, #03, #00, #88, #7f, #80, #fc, #03, #00, #cf

#6d1a

#059a

16

        db #ff, #00, #fc, #03, #07, #38, #ff, #00, #fc, #03, #07, #08, #ff, #00, #fc, #02

#6d2a

#05aa

16

        db #0f, #10, #ff, #00, #fc, #03, #0f, #10, #ff, #00, #ff, #00, #1f, #e0, #ff, #00

#6d3a

#05ba

6

        db #ff, #00, #df, #20, #ff, #00

#6d40

#05c0

    L6d40_iso_graphic_5:  ;

#6d40

#05c0

16

        db #1e, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #e7, #18, #ff, #00

#6d50

#05d0

16

        db #ff, #00, #ff, #00, #e1, #16, #ff, #00, #ff, #00, #ff, #00, #c0, #35, #7f, #80

#6d60

#05e0

16

        db #ff, #00, #ff, #00, #c0, #35, #1f, #60, #ff, #00, #ff, #00, #80, #7d, #07, #58

#6d70

#05f0

16

        db #ff, #00, #ff, #00, #80, #65, #01, #56, #ff, #00, #ff, #00, #80, #63, #00, #55

#6d80

#0600

16

        db #7f, #80, #ff, #00, #80, #41, #00, #55, #3f, #40, #fe, #01, #00, #e0, #00, #d5

#6d90

#0610

16

        db #3f, #40, #fe, #01, #00, #71, #00, #d5, #3f, #40, #fc, #03, #00, #59, #00, #8f

#6da0

#0620

16

        db #3f, #c0, #fc, #03, #00, #57, #00, #88, #3f, #40, #f8, #07, #00, #d7, #00, #88

#6db0

#0630

16

        db #7f, #80, #f8, #06, #00, #57, #00, #88, #7f, #80, #f8, #06, #00, #37, #00, #cf

#6dc0

#0640

16

        db #ff, #00, #f8, #04, #00, #17, #07, #38, #ff, #00, #f8, #06, #00, #0f, #03, #0c

#6dd0

#0650

16

        db #ff, #00, #fe, #01, #00, #1a, #03, #14, #ff, #00, #ff, #00, #00, #9b, #03, #1c

#6de0

#0660

16

        db #ff, #00, #ff, #00, #80, #78, #03, #f4, #ff, #00, #ff, #00, #c0, #38, #07, #a8

#6df0

#0670

16

        db #ff, #00, #ff, #00, #c0, #38, #07, #88, #ff, #00, #ff, #00, #c0, #3c, #0f, #f0

#6e00

#0680

16

        db #ff, #00, #ff, #00, #c0, #33, #7f, #80, #ff, #00, #ff, #00, #c0, #30, #7f, #80

#6e10

#0690

16

        db #ff, #00, #ff, #00, #c0, #21, #ff, #00, #ff, #00, #ff, #00, #c0, #31, #ff, #00

#6e20

#06a0

16

        db #ff, #00, #ff, #00, #f0, #0e, #ff, #00, #ff, #00, #ff, #00, #fc, #02, #ff, #00

#6e30

#06b0

2

        db #ff, #00

#6e32

#06b2

    L6e32_iso_graphic_6:  ;

#6e32

#06b2

16

        db #1d, #03, #ff, #00, #ff, #00, #ff, #00, #fe, #01, #7f, #80, #ff, #00, #fe, #01

#6e42

#06c2

16

        db #1f, #60, #ff, #00, #fc, #03, #07, #58, #ff, #00, #fc, #03, #03, #54, #ff, #00

#6e52

#06d2

16

        db #f8, #07, #02, #d5, #7f, #80, #f8, #06, #02, #75, #1f, #60, #f0, #0e, #00, #1f

#6e62

#06e2

16

        db #07, #58, #f0, #0e, #00, #07, #03, #54, #e0, #1e, #00, #07, #03, #d4, #e0, #1c

#6e72

#06f2

16

        db #00, #0e, #03, #74, #c0, #3c, #00, #0e, #03, #1c, #c0, #3f, #00, #0e, #03, #04

#6e82

#0702

16

        db #80, #7c, #00, #de, #03, #04, #80, #7c, #00, #3c, #07, #08, #80, #7c, #00, #1c

#6e92

#0712

16

        db #07, #08, #80, #5c, #00, #1f, #07, #08, #80, #7e, #00, #1c, #0f, #d0, #e0, #19

#6ea2

#0722

16

        db #00, #9c, #0f, #30, #e0, #18, #00, #7c, #0f, #10, #e0, #10, #00, #1c, #0f, #10

#6eb2

#0732

16

        db #e0, #18, #00, #3e, #0f, #10, #f8, #06, #00, #39, #0f, #90, #fe, #01, #20, #d8

#6ec2

#0742

16

        db #0f, #70, #ff, #00, #a0, #50, #0f, #10, #ff, #00, #e0, #18, #1f, #20, #ff, #00

#6ed2

#0752

16

        db #f8, #06, #1f, #20, #ff, #00, #fe, #01, #3f, #c0, #ff, #00, #ff, #00, #bf, #40

#6ee2

#0762

    L6ee2_iso_graphic_7:  ;

#6ee2

#0762

16

        db #1d, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #e7, #18, #ff, #00

#6ef2

#0772

16

        db #ff, #00, #ff, #00, #e1, #16, #ff, #00, #ff, #00, #ff, #00, #c0, #35, #7f, #80

#6f02

#0782

16

        db #ff, #00, #ff, #00, #c0, #35, #3f, #40, #ff, #00, #ff, #00, #80, #7d, #27, #58

#6f12

#0792

16

        db #ff, #00, #ff, #00, #80, #67, #21, #56, #ff, #00, #ff, #00, #00, #e1, #00, #f5

#6f22

#07a2

16

        db #7f, #80, #ff, #00, #00, #e0, #00, #75, #3f, #40, #fe, #01, #00, #e0, #00, #7d

#6f32

#07b2

16

        db #3f, #40, #fe, #01, #00, #c0, #00, #e7, #3f, #40, #fc, #03, #00, #c0, #00, #e1

#6f42

#07c2

16

        db #3f, #c0, #fc, #03, #00, #f0, #00, #e0, #3f, #40, #f8, #07, #00, #cd, #00, #e0

#6f52

#07d2

16

        db #3f, #40, #f8, #07, #00, #c3, #00, #c0, #7f, #80, #f8, #07, #00, #c1, #00, #c0

#6f62

#07e2

16

        db #7f, #80, #f8, #05, #00, #c1, #00, #f0, #7f, #80, #f8, #07, #00, #e1, #00, #cd

#6f72

#07f2

16

        db #ff, #00, #fe, #01, #00, #99, #00, #c3, #ff, #00, #fe, #01, #00, #87, #00, #c1

#6f82

#0802

16

        db #ff, #00, #fe, #01, #00, #01, #00, #c1, #ff, #00, #fe, #01, #00, #83, #00, #e1

#6f92

#0812

16

        db #ff, #00, #ff, #00, #80, #63, #00, #99, #ff, #00, #ff, #00, #e2, #1d, #00, #87

#6fa2

#0822

16

        db #ff, #00, #ff, #00, #fa, #05, #00, #01, #ff, #00, #ff, #00, #fe, #01, #01, #82

#6fb2

#0832

16

        db #ff, #00, #ff, #00, #ff, #00, #81, #62, #ff, #00, #ff, #00, #ff, #00, #e3, #1c

#6fc2

#0842

10

        db #ff, #00, #ff, #00, #ff, #00, #fb, #04, #ff, #00

#6fcc

#084c

    L6fcc_iso_graphic_8:  ;

#6fcc

#084c

16

        db #17, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #3f, #c0, #ff, #00, #ff, #00

#6fdc

#085c

16

        db #0f, #f0, #ff, #00, #fe, #01, #03, #bc, #ff, #00, #fe, #01, #01, #0e, #ff, #00

#6fec

#086c

16

        db #fc, #03, #01, #42, #3f, #c0, #fc, #02, #00, #2a, #0f, #f0, #fc, #03, #00, #f5

#6ffc

#087c

16

        db #03, #bc, #ff, #00, #00, #f5, #01, #0e, #f3, #0c, #c0, #3b, #01, #42, #f0, #0f

#700c

#088c

16

        db #c0, #32, #01, #2a, #e0, #1b, #00, #cf, #03, #f4, #e0, #10, #00, #c3, #03, #f4

#701c

#089c

16

        db #c0, #34, #00, #98, #07, #f8, #c0, #22, #00, #a6, #1f, #20, #c0, #3f, #00, #22

#702c

#08ac

16

        db #3f, #40, #f0, #0f, #00, #42, #1f, #e0, #fc, #02, #00, #64, #1f, #a0, #fc, #03

#703c

#08bc

16

        db #00, #1d, #1f, #a0, #ff, #00, #00, #c1, #3f, #40, #ff, #00, #c0, #33, #3f, #40

#704c

#08cc

12

        db #ff, #00, #f0, #0f, #7f, #80, #ff, #00, #fd, #02, #ff, #00

#7058

#08d8

    L7058_iso_graphic_9:  ;

#7058

#08d8

16

        db #17, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #f3, #0c, #ff, #00

#7068

#08e8

16

        db #ff, #00, #ff, #00, #f0, #0f, #ff, #00, #ff, #00, #ff, #00, #e0, #1b, #3f, #c0

#7078

#08f8

16

        db #ff, #00, #ff, #00, #e0, #10, #1f, #e0, #ff, #00, #ff, #00, #c0, #34, #13, #2c

#7088

#0908

16

        db #ff, #00, #ff, #00, #c0, #22, #00, #af, #ff, #00, #ff, #00, #c0, #3f, #00, #5b

#7098

#0918

16

        db #3f, #c0, #ff, #00, #f0, #0f, #00, #50, #1f, #e0, #ff, #00, #3c, #c3, #00, #b4

#70a8

#0928

16

        db #1f, #20, #ff, #00, #0c, #f3, #00, #22, #1f, #a0, #fe, #01, #00, #bc, #00, #ff

#70b8

#0938

16

        db #3f, #40, #fe, #01, #00, #0c, #00, #3f, #3f, #40, #fc, #03, #00, #49, #00, #8f

#70c8

#0948

16

        db #7f, #80, #fc, #02, #00, #2a, #01, #62, #ff, #00, #fc, #03, #00, #f2, #03, #24

#70d8

#0958

16

        db #ff, #00, #ff, #00, #00, #f4, #01, #2e, #ff, #00, #ff, #00, #c0, #26, #01, #4a

#70e8

#0968

16

        db #ff, #00, #ff, #00, #c0, #31, #01, #da, #ff, #00, #ff, #00, #f0, #0c, #03, #14

#70f8

#0978

16

        db #ff, #00, #ff, #00, #fc, #03, #03, #34, #ff, #00, #ff, #00, #ff, #00, #07, #f8

#7108

#0988

10

        db #ff, #00, #ff, #00, #ff, #00, #df, #20, #ff, #00

#7112

#0992

    L7112_iso_graphic_10:  ;

#7112

#0992

16

        db #1c, #03, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #0f, #b0, #ff, #00, #fe, #01

#7122

#09a2

16

        db #03, #ac, #ff, #00, #fe, #01, #00, #ab, #ff, #00, #fc, #03, #00, #aa, #3f, #c0

#7132

#09b2

16

        db #fc, #02, #00, #aa, #0f, #b0, #f8, #07, #00, #ea, #03, #ac, #f8, #05, #00, #3a

#7142

#09c2

16

        db #00, #ab, #f0, #0f, #00, #0e, #00, #ab, #f0, #0a, #00, #03, #01, #ae, #e0, #1e

#7152

#09d2

16

        db #00, #60, #01, #fa, #e0, #14, #00, #98, #03, #34, #c0, #3c, #00, #86, #03, #14

#7162

#09e2

16

        db #c0, #29, #00, #01, #07, #a8, #80, #79, #00, #01, #07, #28, #80, #52, #00, #01

#7172

#09f2

16

        db #07, #78, #00, #f3, #00, #82, #03, #5c, #00, #a4, #00, #62, #1f, #a0, #00, #e4

#7182

#0a02

16

        db #00, #1c, #1f, #a0, #00, #c8, #00, #05, #3f, #40, #00, #c8, #00, #09, #3f, #40

#7192

#0a12

16

        db #00, #8c, #00, #0b, #3f, #c0, #00, #c3, #00, #12, #1f, #e0, #c0, #30, #00, #d5

#71a2

#0a22

16

        db #ff, #00, #f0, #0c, #01, #27, #ff, #00, #fc, #03, #01, #0a, #ff, #00, #ff, #00

#71b2

#0a32

10

        db #03, #cc, #ff, #00, #ff, #00, #c7, #38, #ff, #00

#71bc

#0a3c

    L71bc_iso_graphic_11:  ;

#71bc

#0a3c

16

        db #1c, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0b, #ff, #00

#71cc

#0a4c

16

        db #ff, #00, #ff, #00, #e0, #1a, #3f, #c0, #ff, #00, #ff, #00, #e0, #1a, #0f, #b0

#71dc

#0a5c

16

        db #ff, #00, #ff, #00, #c0, #3a, #03, #ac, #ff, #00, #ff, #00, #c0, #2a, #00, #ab

#71ec

#0a6c

16

        db #ff, #00, #ff, #00, #80, #7e, #00, #aa, #3f, #c0, #ff, #00, #80, #53, #00, #aa

#71fc

#0a7c

16

        db #0f, #b0, #ff, #00, #00, #f0, #00, #ea, #0f, #b0, #ff, #00, #00, #a0, #00, #3a

#720c

#0a8c

16

        db #1f, #e0, #fe, #01, #00, #e6, #00, #0f, #1f, #a0, #fe, #01, #00, #49, #00, #83

#721c

#0a9c

16

        db #3f, #40, #fc, #03, #00, #c8, #00, #61, #3f, #40, #fc, #02, #00, #90, #00, #1a

#722c

#0aac

16

        db #7f, #80, #f8, #07, #00, #90, #00, #12, #7f, #80, #f8, #05, #00, #20, #00, #17

#723c

#0abc

16

        db #7f, #80, #f0, #0f, #00, #38, #00, #25, #3f, #c0, #f0, #0a, #00, #46, #01, #2a

#724c

#0acc

16

        db #ff, #00, #f0, #0e, #00, #41, #01, #ca, #ff, #00, #f0, #0c, #00, #80, #03, #54

#725c

#0adc

16

        db #ff, #00, #f0, #0c, #00, #80, #03, #94, #ff, #00, #f0, #08, #00, #c0, #03, #bc

#726c

#0aec

16

        db #ff, #00, #f0, #0c, #00, #31, #01, #2e, #ff, #00, #fc, #03, #00, #0d, #0f, #50

#727c

#0afc

16

        db #ff, #00, #ff, #00, #00, #c2, #1f, #70, #ff, #00, #ff, #00, #c0, #30, #1f, #a0

#728c

#0b0c

16

        db #ff, #00, #ff, #00, #f0, #0c, #3f, #c0, #ff, #00, #ff, #00, #fc, #03, #7f, #80

#729c

#0b1c

2

        db #ff, #00

#729e

#0b1e

    L729e_iso_graphic_12:  ;

#729e

#0b1e

16

        db #1e, #03, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #0f, #b0, #ff, #00, #fe, #01

#72ae

#0b2e

16

        db #03, #3c, #ff, #00, #fe, #01, #00, #17, #ff, #00, #fc, #02, #00, #1d, #3f, #c0

#72be

#0b3e

16

        db #fc, #02, #00, #0d, #0f, #70, #f8, #04, #00, #0d, #03, #5c, #e0, #1c, #00, #05

#72ce

#0b4e

16

        db #00, #57, #f0, #0f, #00, #47, #00, #55, #f0, #09, #00, #c9, #00, #d5, #e0, #14

#72de

#0b5e

16

        db #00, #48, #00, #75, #e0, #12, #00, #12, #00, #1d, #c0, #21, #00, #15, #00, #87

#72ee

#0b6e

16

        db #00, #e0, #00, #a4, #00, #61, #80, #7a, #00, #a8, #01, #1a, #80, #4e, #00, #48

#72fe

#0b7e

16

        db #01, #12, #00, #c2, #00, #50, #03, #14, #00, #f0, #00, #90, #03, #24, #80, #50

#730e

#0b8e

16

        db #00, #ac, #07, #28, #c0, #29, #00, #23, #07, #48, #c0, #29, #00, #40, #0f, #d0

#731e

#0b9e

16

        db #e0, #1a, #00, #40, #0f, #90, #e0, #1a, #00, #80, #1f, #a0, #f0, #0c, #00, #e1

#732e

#0bae

16

        db #1f, #20, #f8, #06, #00, #19, #3f, #40, #fe, #01, #00, #86, #3f, #40, #ff, #00

#733e

#0bbe

16

        db #80, #62, #7f, #80, #ff, #00, #e0, #18, #7f, #80, #ff, #00, #f8, #07, #ff, #00

#734e

#0bce

6

        db #ff, #00, #fe, #01, #ff, #00

#7354

#0bd4

    L7354_iso_graphic_13:  ;

#7354

#0bd4

16

        db #1e, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0b, #ff, #00

#7364

#0be4

16

        db #ff, #00, #ff, #00, #e0, #13, #3f, #c0, #ff, #00, #ff, #00, #e0, #11, #0f, #70

#7374

#0bf4

16

        db #ff, #00, #ff, #00, #c0, #21, #03, #dc, #ff, #00, #ff, #00, #c0, #20, #00, #d7

#7384

#0c04

16

        db #ff, #00, #ff, #00, #80, #40, #00, #d5, #3f, #c0, #fe, #01, #00, #c0, #00, #55

#7394

#0c14

16

        db #0f, #70, #ff, #00, #00, #f4, #00, #75, #0f, #50, #ff, #00, #00, #9c, #00, #9d

#73a4

#0c24

16

        db #0f, #50, #fe, #01, #00, #44, #00, #87, #0f, #50, #fe, #01, #00, #21, #00, #21

#73b4

#0c34

16

        db #0f, #d0, #fc, #02, #00, #11, #00, #58, #0f, #70, #f0, #0e, #00, #0a, #00, #46

#73c4

#0c44

16

        db #0f, #10, #f8, #07, #00, #aa, #00, #81, #1f, #a0, #f8, #04, #00, #e4, #00, #81

#73d4

#0c54

16

        db #1f, #20, #f0, #0c, #00, #25, #00, #01, #3f, #40, #f0, #0f, #00, #09, #00, #02

#73e4

#0c64

16

        db #3f, #40, #f8, #05, #00, #0a, #00, #c2, #7f, #80, #fc, #02, #00, #92, #00, #34

#73f4

#0c74

16

        db #7f, #80, #fc, #02, #00, #94, #00, #0d, #ff, #00, #fe, #01, #00, #a4, #00, #09

#7404

#0c84

16

        db #ff, #00, #fe, #01, #00, #a8, #01, #0a, #ff, #00, #ff, #00, #00, #ce, #01, #12

#7414

#0c94

16

        db #ff, #00, #ff, #00, #80, #61, #03, #94, #ff, #00, #ff, #00, #e0, #18, #03, #64

#7424

#0ca4

16

        db #ff, #00, #ff, #00, #f8, #06, #07, #28, #ff, #00, #ff, #00, #fe, #01, #07, #88

#7434

#0cb4

16

        db #ff, #00, #ff, #00, #ff, #00, #8f, #70, #ff, #00, #ff, #00, #ff, #00, #ef, #10

#7444

#0cc4

2

        db #ff, #00

#7446

#0cc6

    L7446_iso_graphic_14:  ;

#7446

#0cc6

16

        db #1e, #03, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #0f, #b0, #ff, #00, #fe, #01

#7456

#0cd6

16

        db #03, #8c, #ff, #00, #fe, #01, #00, #87, #ff, #00, #fc, #03, #00, #04, #3f, #c0

#7466

#0ce6

16

        db #fc, #03, #00, #09, #0f, #30, #f8, #07, #00, #09, #03, #0c, #f8, #07, #00, #32

#7476

#0cf6

16

        db #00, #0b, #f0, #0a, #00, #32, #00, #11, #f0, #0a, #00, #32, #00, #13, #e0, #1b

#7486

#0d06

16

        db #00, #04, #00, #63, #e0, #1c, #00, #c4, #01, #62, #c0, #2c, #00, #34, #01, #66

#7496

#0d16

16

        db #c0, #29, #00, #8c, #01, #06, #80, #69, #00, #63, #01, #06, #80, #72, #00, #18

#74a6

#0d26

16

        db #03, #c4, #00, #b2, #00, #0e, #03, #34, #00, #a4, #00, #09, #03, #8c, #00, #a4

#74b6

#0d36

16

        db #00, #10, #07, #48, #00, #c8, #00, #10, #07, #48, #00, #c8, #00, #20, #0f, #90

#74c6

#0d46

16

        db #00, #98, #00, #20, #0f, #90, #00, #c6, #00, #41, #1f, #20, #c0, #31, #00, #c1

#74d6

#0d56

16

        db #1f, #20, #f0, #0c, #00, #62, #3f, #40, #fc, #03, #00, #1a, #3f, #40, #ff, #00

#74e6

#0d66

16

        db #00, #c4, #7f, #80, #ff, #00, #c0, #30, #7f, #80, #ff, #00, #f0, #0d, #ff, #00

#74f6

#0d76

6

        db #ff, #00, #fc, #03, #ff, #00

#74fc

#0d7c

    L74fc_iso_graphic_15:  ;

#74fc

#0d7c

16

        db #1e, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0b, #ff, #00

#750c

#0d8c

16

        db #ff, #00, #ff, #00, #e0, #18, #3f, #c0, #ff, #00, #ff, #00, #e0, #18, #0f, #70

#751c

#0d9c

16

        db #ff, #00, #ff, #00, #c0, #30, #03, #4c, #ff, #00, #ff, #00, #c0, #30, #00, #93

#752c

#0dac

16

        db #ff, #00, #ff, #00, #80, #70, #00, #90, #3f, #c0, #ff, #00, #80, #73, #00, #20

#753c

#0dbc

16

        db #0f, #b0, #ff, #00, #00, #a3, #00, #21, #0f, #10, #ff, #00, #00, #a3, #00, #21

#754c

#0dcc

16

        db #0f, #30, #fe, #01, #00, #b0, #00, #46, #0f, #30, #fe, #01, #00, #cc, #00, #46

#755c

#0ddc

16

        db #1f, #20, #fc, #02, #00, #c3, #00, #46, #1f, #60, #fc, #02, #00, #98, #00, #c0

#756c

#0dec

16

        db #1f, #60, #f8, #06, #00, #96, #00, #30, #1f, #60, #f8, #07, #00, #21, #00, #8c

#757c

#0dfc

16

        db #3f, #40, #f0, #0b, #00, #20, #00, #e3, #3f, #40, #f0, #0a, #00, #40, #00, #98

#758c

#0e0c

16

        db #3f, #c0, #f0, #0a, #00, #41, #00, #04, #7f, #80, #f0, #0c, #00, #81, #00, #04

#759c

#0e1c

16

        db #7f, #80, #f0, #0c, #00, #82, #00, #09, #ff, #00, #f0, #09, #00, #82, #00, #09

#75ac

#0e2c

16

        db #ff, #00, #f0, #0c, #00, #64, #01, #12, #ff, #00, #fc, #03, #00, #1c, #01, #12

#75bc

#0e3c

16

        db #ff, #00, #ff, #00, #00, #c6, #03, #24, #ff, #00, #ff, #00, #c0, #31, #03, #a4

#75cc

#0e4c

16

        db #ff, #00, #ff, #00, #f0, #0c, #07, #48, #ff, #00, #ff, #00, #fc, #03, #07, #08

#75dc

#0e5c

16

        db #ff, #00, #ff, #00, #ff, #00, #0f, #d0, #ff, #00, #ff, #00, #ff, #00, #cf, #30

#75ec

#0e6c

2

        db #ff, #00

#75ee

#0e6e

    L75ee_iso_graphic_16:  ;

#75ee

#0e6e

16

        db #19, #03, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #0f, #f0, #ff, #00, #fe, #01

#75fe

#0e7e

16

        db #03, #fc, #ff, #00, #fe, #01, #00, #ff, #ff, #00, #fc, #02, #00, #df, #3f, #c0

#760e

#0e8e

16

        db #fc, #02, #00, #f7, #0f, #f0, #f8, #06, #00, #fd, #03, #fc, #f8, #07, #00, #3f

#761e

#0e9e

16

        db #00, #7f, #f0, #0b, #00, #0f, #00, #df, #f0, #0a, #00, #63, #00, #f7, #e0, #1a

#762e

#0eae

16

        db #00, #58, #00, #fd, #e0, #1c, #00, #86, #00, #3f, #c0, #2c, #00, #83, #00, #8f

#763e

#0ebe

16

        db #c0, #29, #00, #04, #00, #63, #80, #69, #00, #04, #01, #12, #80, #72, #00, #08

#764e

#0ece

16

        db #01, #12, #00, #f1, #00, #88, #03, #24, #00, #cc, #00, #70, #03, #24, #c0, #33

#765e

#0ede

16

        db #00, #18, #07, #48, #f0, #0e, #00, #c6, #07, #48, #f0, #07, #00, #31, #0f, #90

#766e

#0eee

16

        db #f1, #04, #00, #cc, #0f, #10, #ff, #00, #e0, #3b, #1f, #20, #ff, #00, #c0, #1d

#767e

#0efe

8

        db #1f, #e0, #ff, #00, #c0, #13, #7f, #80

#7686

#0f06

    L7686_iso_graphic_17:  ;

#7686

#0f06

16

        db #19, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0f, #ff, #00

#7696

#0f16

16

        db #ff, #00, #ff, #00, #e0, #1f, #3f, #c0, #ff, #00, #ff, #00, #e0, #1f, #0f, #f0

#76a6

#0f26

16

        db #ff, #00, #ff, #00, #c0, #2d, #03, #fc, #ff, #00, #ff, #00, #c0, #2f, #00, #7f

#76b6

#0f36

16

        db #ff, #00, #ff, #00, #80, #6f, #00, #df, #3f, #c0, #ff, #00, #80, #73, #00, #f7

#76c6

#0f46

16

        db #0f, #f0, #ff, #00, #00, #b0, #00, #fd, #0f, #f0, #ff, #00, #00, #a6, #00, #3f

#76d6

#0f56

16

        db #0f, #70, #fe, #01, #00, #a5, #00, #8f, #0f, #d0, #fe, #01, #00, #c8, #00, #63

#76e6

#0f66

16

        db #0f, #f0, #fc, #02, #00, #c8, #00, #38, #0f, #f0, #fc, #02, #00, #90, #00, #46

#76f6

#0f76

16

        db #0f, #30, #f8, #06, #00, #90, #00, #41, #1f, #20, #f8, #07, #00, #20, #00, #81

#7706

#0f86

16

        db #1f, #20, #f0, #0f, #00, #18, #00, #82, #3f, #40, #f0, #0c, #00, #c7, #00, #02

#7716

#0f96

16

        db #3f, #40, #fc, #03, #00, #31, #00, #84, #7f, #80, #ff, #00, #00, #ec, #00, #64

#7726

#0fa6

16

        db #7f, #80, #ff, #00, #00, #73, #00, #19, #ff, #00, #ff, #00, #10, #4c, #00, #c1

#7736

#0fb6

16

        db #ff, #00, #ff, #00, #dc, #03, #01, #b2, #ff, #00, #ff, #00, #fc, #01, #01, #de

#7746

#0fc6

10

        db #ff, #00, #ff, #00, #fc, #01, #07, #38, #ff, #00

#7750

#0fd0

    L7750_iso_graphic_18:  ;

#7750

#0fd0

16

        db #1b, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #fe, #01

#7760

#0fe0

16

        db #ff, #00, #ff, #00, #fe, #01, #3f, #c0, #ff, #00, #fc, #02, #0f, #b0, #ff, #00

#7770

#0ff0

16

        db #fc, #02, #03, #8c, #ff, #00, #fc, #03, #00, #03, #ff, #00, #fe, #01, #00, #08

#7780

#1000

16

        db #3f, #c0, #ff, #00, #00, #c8, #0f, #30, #ff, #00, #00, #f0, #03, #8c, #ff, #00

#7790

#1010

16

        db #00, #ec, #01, #82, #fe, #01, #00, #43, #00, #09, #fe, #01, #00, #c0, #00, #c9

#77a0

#1020

16

        db #fc, #02, #00, #b0, #00, #31, #bc, #43, #00, #8c, #31, #4e, #88, #75, #00, #63

#77b0

#1030

16

        db #3f, #40, #00, #af, #00, #18, #7f, #80, #00, #a6, #00, #c6, #7f, #80, #00, #c6

#77c0

#1040

16

        db #00, #31, #ff, #00, #80, #44, #00, #0d, #ff, #00, #c0, #33, #01, #02, #ff, #00

#77d0

#1050

16

        db #f0, #0c, #00, #c3, #ff, #00, #fc, #03, #00, #34, #7f, #80, #ff, #00, #00, #cc

#77e0

#1060

16

        db #3f, #40, #ff, #00, #c0, #30, #3f, #40, #ff, #00, #f0, #0c, #3f, #40, #ff, #00

#77f0

#1070

4

        db #fc, #03, #7f, #80

#77f4

#1074

    L77f4_iso_graphic_19:  ;

#77f4

#1074

16

        db #1b, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#7804

#1084

16

        db #ff, #00, #ff, #00, #ef, #10, #ff, #00, #ff, #00, #ff, #00, #e3, #1c, #ff, #00

#7814

#1094

16

        db #ff, #00, #ff, #00, #c0, #2b, #ff, #00, #ff, #00, #ff, #00, #c0, #28, #3f, #c0

#7824

#10a4

16

        db #ff, #00, #ff, #00, #c0, #30, #0f, #30, #ff, #00, #ff, #00, #e0, #10, #03, #8c

#7834

#10b4

16

        db #ff, #00, #ff, #00, #f0, #0c, #00, #83, #ff, #00, #ff, #00, #f0, #0f, #00, #08

#7844

#10c4

16

        db #3f, #c0, #ff, #00, #f0, #0e, #00, #c8, #1f, #20, #ff, #00, #e0, #14, #00, #30

#7854

#10d4

16

        db #0f, #90, #ff, #00, #e0, #1c, #00, #0c, #0f, #90, #ff, #00, #c0, #2b, #00, #03

#7864

#10e4

16

        db #0f, #10, #fb, #04, #c0, #38, #03, #c4, #1f, #e0, #f8, #07, #80, #56, #03, #34

#7874

#10f4

16

        db #ff, #00, #f0, #0a, #00, #f1, #07, #88, #ff, #00, #f0, #0a, #00, #6c, #07, #68

#7884

#1104

16

        db #ff, #00, #f0, #0c, #00, #63, #0f, #10, #ff, #00, #f8, #04, #00, #40, #0f, #d0

#7894

#1114

16

        db #ff, #00, #fc, #03, #00, #30, #1f, #20, #ff, #00, #ff, #00, #00, #cc, #0f, #30

#78a4

#1124

16

        db #ff, #00, #ff, #00, #c0, #33, #07, #48, #ff, #00, #ff, #00, #f0, #0c, #03, #c4

#78b4

#1134

16

        db #ff, #00, #ff, #00, #fc, #03, #03, #04, #ff, #00, #ff, #00, #ff, #00, #03, #c4

#78c4

#1144

10

        db #ff, #00, #ff, #00, #ff, #00, #c7, #38, #ff, #00

#78ce

#114e

    L78ce_iso_graphic_20:  ;

#78ce

#114e

16

        db #1c, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #9f, #60, #ff, #00, #ff, #00

#78de

#115e

16

        db #0f, #90, #ff, #00, #ff, #00, #07, #88, #ff, #00, #fe, #01, #07, #88, #ff, #00

#78ee

#116e

16

        db #fe, #01, #07, #48, #ff, #00, #fc, #02, #03, #3c, #f3, #0c, #fc, #02, #00, #17

#78fe

#117e

16

        db #e1, #12, #f8, #04, #00, #3d, #20, #d1, #f8, #05, #00, #37, #00, #71, #f0, #08

#790e

#118e

16

        db #00, #fd, #00, #e9, #f0, #08, #00, #4f, #01, #46, #e0, #10, #00, #93, #01, #c2

#791e

#119e

16

        db #e0, #14, #00, #94, #03, #e4, #c0, #23, #00, #25, #03, #34, #c0, #21, #00, #29

#792e

#11ae

16

        db #07, #28, #80, #42, #00, #4a, #07, #28, #80, #52, #00, #52, #0f, #50, #00, #8e

#793e

#11be

16

        db #00, #94, #0f, #50, #02, #85, #00, #a4, #1f, #a0, #07, #88, #80, #68, #1f, #a0

#794e

#11ce

16

        db #87, #48, #e0, #19, #3f, #40, #cf, #30, #f0, #0d, #3f, #40, #ff, #00, #e0, #12

#795e

#11de

16

        db #7f, #80, #ff, #00, #e0, #10, #7f, #80, #ff, #00, #e0, #11, #ff, #00, #ff, #00

#796e

#11ee

10

        db #f0, #09, #ff, #00, #ff, #00, #f9, #06, #ff, #00

#7978

#11f8

    L7978_iso_graphic_21:  ;

#7978

#11f8

16

        db #1c, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #f9, #06, #ff, #00

#7988

#1208

16

        db #ff, #00, #ff, #00, #f0, #09, #ff, #00, #ff, #00, #ff, #00, #f0, #08, #7f, #80

#7998

#1218

16

        db #ff, #00, #ff, #00, #e0, #18, #7f, #80, #ff, #00, #ff, #00, #e0, #14, #7f, #80

#79a8

#1228

16

        db #ff, #00, #ff, #00, #c0, #23, #3f, #c0, #3f, #c0, #ff, #00, #c0, #21, #0e, #71

#79b8

#1238

16

        db #1f, #20, #ff, #00, #80, #43, #02, #dd, #0f, #10, #ff, #00, #80, #53, #00, #77

#79c8

#1248

16

        db #0f, #10, #ff, #00, #00, #8f, #00, #de, #0f, #90, #ff, #00, #00, #84, #00, #f4

#79d8

#1258

16

        db #1f, #60, #fe, #01, #00, #09, #00, #3c, #1f, #20, #fe, #01, #00, #49, #00, #4e

#79e8

#1268

16

        db #3f, #40, #fc, #02, #00, #32, #00, #53, #3f, #40, #fc, #02, #00, #12, #00, #92

#79f8

#1278

16

        db #7f, #80, #f8, #04, #00, #24, #00, #a2, #7f, #80, #f8, #05, #00, #25, #00, #25

#7a08

#1288

16

        db #ff, #00, #f0, #08, #00, #e9, #00, #45, #ff, #00, #f0, #08, #20, #5a, #01, #4a

#7a18

#1298

16

        db #ff, #00, #f0, #08, #78, #86, #01, #8a, #ff, #00, #f8, #04, #7e, #81, #03, #94

#7a28

#12a8

16

        db #ff, #00, #fc, #03, #ff, #00, #03, #d4, #ff, #00, #ff, #00, #fe, #01, #07, #28

#7a38

#12b8

16

        db #ff, #00, #ff, #00, #fe, #01, #07, #08, #ff, #00, #ff, #00, #fe, #01, #0f, #10

#7a48

#12c8

16

        db #ff, #00, #ff, #00, #ff, #00, #0f, #90, #ff, #00, #ff, #00, #ff, #00, #9f, #60

#7a58

#12d8

2

        db #ff, #00

#7a5a

#12da

    L7a5a_iso_graphic_22:  ;

#7a5a

#12da

16

        db #1c, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #8f, #70, #ff, #00, #ff, #00

#7a6a

#12ea

16

        db #03, #8c, #ff, #00, #fe, #01, #00, #03, #ff, #00, #fc, #02, #00, #20, #3f, #c0

#7a7a

#12fa

16

        db #fc, #02, #00, #a4, #0f, #b0, #f8, #04, #00, #a4, #0f, #90, #f8, #04, #00, #04

#7a8a

#130a

16

        db #07, #88, #f0, #0a, #00, #70, #07, #88, #f0, #09, #00, #8c, #07, #88, #e0, #16

#7a9a

#131a

16

        db #00, #03, #0f, #90, #e0, #12, #00, #00, #0f, #90, #c0, #24, #00, #61, #1f, #20

#7aaa

#132a

16

        db #c0, #34, #00, #19, #1f, #20, #c0, #28, #00, #03, #3f, #c0, #80, #48, #00, #03

#7aba

#133a

16

        db #0f, #f0, #80, #71, #00, #87, #0f, #70, #80, #50, #00, #65, #0f, #d0, #80, #60

#7aca

#134a

16

        db #00, #08, #0f, #70, #80, #60, #00, #0c, #0f, #10, #80, #46, #00, #13, #1f, #20

#7ada

#135a

16

        db #80, #41, #03, #9c, #1f, #e0, #80, #40, #1f, #20, #ff, #00, #c0, #20, #1f, #20

#7aea

#136a

16

        db #ff, #00, #e0, #10, #3f, #40, #ff, #00, #f0, #0c, #3f, #40, #ff, #00, #fc, #03

#7afa

#137a

10

        db #7f, #80, #ff, #00, #ff, #00, #7f, #80, #ff, #00

#7b04

#1384

    L7b04_iso_graphic_23:  ;

#7b04

#1384

16

        db #1c, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #f8, #07, #ff, #00

#7b14

#1394

16

        db #ff, #00, #ff, #00, #f0, #08, #3f, #c0, #ff, #00, #ff, #00, #e0, #10, #0f, #30

#7b24

#13a4

16

        db #ff, #00, #ff, #00, #c0, #22, #03, #0c, #ff, #00, #ff, #00, #c0, #2a, #00, #4b

#7b34

#13b4

16

        db #ff, #00, #ff, #00, #80, #4a, #00, #49, #ff, #00, #ff, #00, #80, #40, #00, #48

#7b44

#13c4

16

        db #7f, #80, #ff, #00, #00, #a7, #00, #08, #7f, #80, #ff, #00, #00, #98, #00, #c8

#7b54

#13d4

16

        db #7f, #80, #fe, #01, #00, #60, #00, #39, #ff, #00, #fe, #01, #00, #20, #00, #09

#7b64

#13e4

16

        db #ff, #00, #fc, #02, #00, #46, #01, #12, #ff, #00, #fc, #03, #00, #41, #01, #92

#7b74

#13f4

16

        db #ff, #00, #fc, #02, #00, #80, #03, #3c, #ff, #00, #f8, #04, #00, #80, #00, #3f

#7b84

#1404

16

        db #ff, #00, #f8, #07, #00, #18, #00, #77, #ff, #00, #f8, #05, #00, #06, #00, #5d

#7b94

#1414

16

        db #ff, #00, #f8, #06, #00, #00, #00, #87, #ff, #00, #f8, #06, #00, #00, #00, #c1

#7ba4

#1424

16

        db #ff, #00, #f8, #04, #00, #61, #01, #32, #ff, #00, #f8, #04, #00, #19, #31, #ce

#7bb4

#1434

16

        db #ff, #00, #f8, #04, #01, #02, #ff, #00, #ff, #00, #fc, #02, #01, #02, #ff, #00

#7bc4

#1444

16

        db #ff, #00, #fe, #01, #03, #04, #ff, #00, #ff, #00, #ff, #00, #03, #c4, #ff, #00

#7bd4

#1454

16

        db #ff, #00, #ff, #00, #c7, #38, #ff, #00, #ff, #00, #ff, #00, #f7, #08, #ff, #00

#7be4

#1464

2

        db #ff, #00

#7be6

#1466

    L7be6_iso_graphic_24:  ;

#7be6

#1466

16

        db #1d, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#7bf6

#1476

16

        db #ff, #00, #ff, #00, #ff, #00, #f8, #07, #ff, #00, #ff, #00, #c0, #39, #3f, #c0

#7c06

#1486

16

        db #ff, #00, #80, #43, #0f, #30, #ff, #00, #80, #43, #07, #08, #ff, #00, #00, #95

#7c16

#1496

16

        db #07, #48, #f3, #0c, #00, #85, #03, #44, #f0, #0f, #00, #09, #03, #54, #e0, #1f

#7c26

#14a6

16

        db #00, #c9, #03, #14, #e0, #1d, #00, #f1, #03, #c4, #e0, #1f, #00, #72, #03, #34

#7c36

#14b6

16

        db #e0, #1b, #00, #d2, #03, #0c, #e0, #10, #00, #f4, #03, #0c, #e0, #18, #00, #34

#7c46

#14c6

16

        db #03, #04, #f8, #06, #00, #29, #03, #84, #f8, #05, #00, #a8, #03, #64, #fc, #02

#7c56

#14d6

16

        db #00, #d0, #03, #04, #fc, #03, #00, #10, #07, #08, #fe, #01, #00, #26, #07, #08

#7c66

#14e6

16

        db #fe, #01, #00, #21, #0f, #90, #fe, #01, #00, #40, #0f, #10, #fe, #01, #00, #40

#7c76

#14f6

16

        db #1f, #20, #fe, #01, #00, #98, #1f, #20, #fe, #01, #00, #86, #3f, #40, #fe, #01

#7c86

#1506

16

        db #00, #00, #3f, #40, #ff, #00, #00, #e1, #7f, #80, #ff, #00, #e1, #1e, #ff, #00

#7c96

#1516

    L7c96_iso_graphic_25:  ;

#7c96

#1516

16

        db #1d, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#7ca6

#1526

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #8f, #70

#7cb6

#1536

16

        db #ff, #00, #ff, #00, #fc, #03, #03, #9c, #ff, #00, #ff, #00, #f8, #04, #00, #33

#7cc6

#1546

16

        db #ff, #00, #ff, #00, #f8, #04, #00, #30, #7f, #80, #ff, #00, #f0, #09, #00, #54

#7cd6

#1556

16

        db #7f, #80, #ff, #00, #30, #c8, #00, #54, #3f, #40, #ff, #00, #00, #f0, #00, #95

#7ce6

#1566

16

        db #3f, #40, #fe, #01, #00, #fc, #00, #91, #3f, #40, #fe, #01, #00, #df, #00, #1c

#7cf6

#1576

16

        db #3f, #40, #fe, #01, #00, #f7, #00, #23, #3f, #40, #fe, #01, #00, #bd, #00, #20

#7d06

#1586

16

        db #3f, #c0, #fe, #01, #00, #0f, #00, #40, #3f, #c0, #fe, #01, #00, #83, #00, #40

#7d16

#1596

16

        db #3f, #40, #ff, #00, #80, #62, #00, #98, #3f, #40, #ff, #00, #80, #5a, #00, #86

#7d26

#15a6

16

        db #3f, #40, #ff, #00, #c0, #2d, #00, #00, #3f, #40, #ff, #00, #c0, #31, #00, #00

#7d36

#15b6

16

        db #7f, #80, #ff, #00, #e0, #12, #00, #60, #7f, #80, #ff, #00, #e0, #12, #00, #19

#7d46

#15c6

16

        db #ff, #00, #ff, #00, #e0, #14, #00, #01, #ff, #00, #ff, #00, #e0, #14, #01, #02

#7d56

#15d6

16

        db #ff, #00, #ff, #00, #e0, #19, #01, #82, #ff, #00, #ff, #00, #e0, #18, #03, #64

#7d66

#15e6

16

        db #ff, #00, #ff, #00, #e0, #10, #03, #04, #ff, #00, #ff, #00, #f0, #0e, #07, #18

#7d76

#15f6

10

        db #ff, #00, #ff, #00, #fe, #01, #1f, #e0, #ff, #00

#7d80

#1600

    L7d80_iso_graphic_26:  ;

#7d80

#1600

16

        db #1d, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#7d90

#1610

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#7da0

#1620

16

        db #ff, #00, #9c, #63, #ff, #00, #fe, #01, #00, #9e, #3f, #c0, #f8, #06, #00, #06

#7db0

#1630

16

        db #3f, #40, #f0, #0c, #00, #4f, #3f, #40, #f0, #0b, #00, #0c, #1f, #e0, #e0, #18

#7dc0

#1640

16

        db #00, #dc, #0f, #90, #e0, #1a, #00, #19, #0f, #10, #c0, #2a, #00, #b9, #0f, #50

#7dd0

#1650

16

        db #c0, #2a, #00, #b2, #0f, #10, #c0, #28, #00, #b2, #0f, #d0, #c0, #2c, #00, #24

#7de0

#1660

16

        db #0f, #30, #c0, #33, #00, #35, #0f, #10, #c0, #30, #00, #cd, #0f, #50, #c0, #22

#7df0

#1670

16

        db #00, #31, #0f, #50, #c0, #22, #00, #0c, #0f, #50, #c0, #24, #00, #23, #0f, #10

#7e00

#1680

16

        db #c0, #24, #00, #20, #0f, #d0, #c0, #20, #00, #42, #0f, #30, #e0, #10, #00, #42

#7e10

#1690

16

        db #1f, #20, #e0, #10, #00, #04, #1f, #20, #f0, #0c, #00, #04, #3f, #40, #fc, #03

#7e20

#16a0

16

        db #00, #00, #3f, #40, #ff, #00, #00, #e1, #7f, #80, #ff, #00, #e1, #1e, #ff, #00

#7e30

#16b0

    L7e30_iso_graphic_27:  ;

#7e30

#16b0

16

        db #1d, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#7e40

#16c0

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#7e50

#16d0

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #f9, #06, #cf, #30

#7e60

#16e0

16

        db #ff, #00, #ff, #00, #e0, #19, #03, #ec, #ff, #00, #ff, #00, #80, #60, #03, #64

#7e70

#16f0

16

        db #ff, #00, #ff, #00, #00, #c4, #03, #f4, #ff, #00, #ff, #00, #00, #b0, #01, #ce

#7e80

#1700

16

        db #ff, #00, #fe, #01, #00, #8d, #00, #c9, #ff, #00, #fe, #01, #00, #a1, #00, #91

#7e90

#1710

16

        db #ff, #00, #fc, #02, #00, #ab, #00, #95, #ff, #00, #fc, #02, #00, #ab, #00, #21

#7ea0

#1720

16

        db #ff, #00, #fc, #02, #00, #8b, #00, #2d, #ff, #00, #fc, #02, #00, #c2, #00, #43

#7eb0

#1730

16

        db #ff, #00, #fc, #03, #00, #33, #00, #51, #ff, #00, #fc, #03, #00, #0c, #00, #d5

#7ec0

#1740

16

        db #ff, #00, #fc, #02, #00, #23, #00, #15, #ff, #00, #fc, #02, #00, #20, #00, #c5

#7ed0

#1750

16

        db #ff, #00, #fc, #02, #00, #42, #00, #31, #ff, #00, #fc, #02, #00, #42, #00, #0d

#7ee0

#1760

16

        db #ff, #00, #fc, #02, #00, #04, #00, #23, #ff, #00, #fe, #01, #00, #04, #01, #22

#7ef0

#1770

16

        db #ff, #00, #fe, #01, #00, #00, #01, #42, #ff, #00, #ff, #00, #00, #c0, #03, #44

#7f00

#1780

16

        db #ff, #00, #ff, #00, #c0, #30, #03, #04, #ff, #00, #ff, #00, #f0, #0e, #07, #18

#7f10

#1790

10

        db #ff, #00, #ff, #00, #fe, #01, #1f, #e0, #ff, #00

#7f1a

#179a

    L7f1a_iso_graphic_28:  ;

#7f1a

#179a

16

        db #1a, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#7f2a

#17aa

16

        db #8f, #70, #ff, #00, #fe, #01, #03, #8c, #ff, #00, #fc, #02, #00, #03, #ff, #00

#7f3a

#17ba

16

        db #fc, #02, #00, #20, #3f, #c0, #f8, #05, #00, #24, #0f, #30, #f8, #05, #00, #04

#7f4a

#17ca

16

        db #07, #08, #f0, #08, #00, #70, #07, #48, #f0, #0d, #00, #8c, #03, #54, #e0, #1a

#7f5a

#17da

16

        db #00, #03, #03, #14, #e0, #1a, #00, #20, #03, #c4, #c0, #2c, #00, #20, #03, #34

#7f6a

#17ea

16

        db #e0, #1c, #00, #42, #03, #0c, #e0, #18, #00, #42, #03, #0c, #f0, #0c, #00, #04

#7f7a

#17fa

16

        db #03, #24, #fc, #03, #00, #04, #03, #24, #fe, #01, #00, #c0, #03, #44, #fe, #01

#7f8a

#180a

16

        db #00, #f0, #03, #44, #fc, #03, #00, #8c, #07, #08, #fc, #03, #0c, #93, #07, #08

#7f9a

#181a

16

        db #fc, #03, #0f, #10, #0f, #d0, #fc, #03, #1f, #20, #cf, #30, #fc, #02, #1f, #20

#7faa

#182a

14

        db #ff, #00, #fc, #03, #3f, #40, #ff, #00, #ff, #00, #3f, #c0, #ff, #00

#7fb8

#1838

    L7fb8_iso_graphic_29:  ;

#7fb8

#1838

16

        db #1a, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#7fc8

#1848

16

        db #ff, #00, #ff, #00, #f8, #07, #ff, #00, #ff, #00, #ff, #00, #e0, #18, #3f, #c0

#7fd8

#1858

16

        db #ff, #00, #ff, #00, #c0, #20, #0f, #30, #ff, #00, #ff, #00, #c0, #22, #03, #0c

#7fe8

#1868

16

        db #ff, #00, #ff, #00, #80, #52, #00, #43, #ff, #00, #ff, #00, #80, #50, #00, #40

#7ff8

#1878

16

        db #7f, #80, #ff, #00, #00, #87, #00, #04, #7f, #80, #ff, #00, #00, #d8, #00, #c5

#8008

#1888

16

        db #3f, #40, #fe, #01, #00, #a0, #00, #31, #3f, #40, #fe, #01, #00, #a2, #00, #0c

#8018

#1898

16

        db #3f, #40, #fc, #02, #00, #c2, #00, #03, #3f, #40, #fe, #01, #00, #c4, #00, #20

#8028

#18a8

16

        db #3f, #c0, #fe, #01, #00, #84, #00, #20, #3f, #c0, #ff, #00, #00, #c0, #00, #42

#8038

#18b8

16

        db #3f, #40, #ff, #00, #c0, #30, #00, #42, #3f, #40, #ff, #00, #e0, #1c, #00, #04

#8048

#18c8

16

        db #3f, #40, #ff, #00, #e0, #1f, #00, #04, #3f, #40, #ff, #00, #c0, #38, #00, #c0

#8058

#18d8

16

        db #7f, #80, #ff, #00, #c0, #39, #c0, #30, #7f, #80, #ff, #00, #c0, #31, #f0, #0d

#8068

#18e8

16

        db #ff, #00, #ff, #00, #c1, #32, #fc, #03, #ff, #00, #ff, #00, #c1, #22, #ff, #00

#8078

#18f8

16

        db #ff, #00, #ff, #00, #c3, #34, #ff, #00, #ff, #00, #ff, #00, #f3, #0c, #ff, #00

#8088

#1908

2

        db #ff, #00

#808a

#190a

    L808a_iso_graphic_30:  ;

#808a

#190a

16

        db #1d, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#809a

#191a

16

        db #e3, #1c, #ff, #00, #ff, #00, #00, #fb, #ff, #00, #fc, #03, #00, #f8, #3f, #c0

#80aa

#192a

16

        db #fc, #03, #00, #da, #0f, #30, #f8, #07, #00, #78, #0f, #10, #f8, #07, #00, #da

#80ba

#193a

16

        db #0f, #50, #f0, #0b, #00, #78, #07, #18, #f0, #0b, #00, #fc, #07, #58, #e0, #13

#80ca

#194a

16

        db #00, #e3, #07, #18, #e0, #13, #00, #00, #03, #dc, #c0, #24, #00, #7e, #03, #3c

#80da

#195a

16

        db #c0, #25, #00, #ff, #03, #9c, #c0, #29, #00, #3f, #03, #dc, #c0, #2a, #00, #1e

#80ea

#196a

16

        db #03, #cc, #c0, #32, #00, #1c, #03, #6c, #c0, #36, #00, #38, #03, #2c, #c0, #27

#80fa

#197a

16

        db #00, #ec, #03, #24, #c0, #27, #00, #c4, #07, #68, #c0, #27, #00, #ef, #07, #c8

#810a

#198a

16

        db #e0, #17, #00, #3f, #0f, #d0, #e0, #12, #00, #0f, #0f, #90, #e0, #13, #00, #0f

#811a

#199a

16

        db #1f, #a0, #f0, #09, #00, #8f, #1f, #20, #f0, #0c, #00, #7c, #3f, #40, #fc, #03

#812a

#19aa

16

        db #00, #00, #3f, #c0, #ff, #00, #00, #c7, #ff, #00, #ff, #00, #c7, #38, #ff, #00

#813a

#19ba

    L813a_iso_graphic_31:  ;

#813a

#19ba

16

        db #1d, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#814a

#19ca

16

        db #ff, #00, #ff, #00, #fe, #01, #3f, #c0, #ff, #00, #ff, #00, #f0, #0f, #0f, #b0

#815a

#19da

16

        db #ff, #00, #ff, #00, #c0, #3f, #03, #8c, #ff, #00, #ff, #00, #c0, #3d, #00, #a3

#816a

#19ea

16

        db #ff, #00, #ff, #00, #80, #77, #00, #81, #ff, #00, #ff, #00, #80, #7d, #00, #a5

#817a

#19fa

16

        db #ff, #00, #ff, #00, #00, #b7, #00, #81, #7f, #80, #ff, #00, #00, #bf, #00, #c5

#818a

#1a0a

16

        db #7f, #80, #fe, #01, #00, #3e, #00, #31, #7f, #80, #fe, #01, #00, #30, #00, #0d

#819a

#1a1a

16

        db #3f, #c0, #fc, #02, #00, #47, #00, #e3, #3f, #c0, #fc, #02, #00, #5f, #00, #f9

#81aa

#1a2a

16

        db #3f, #c0, #fc, #02, #00, #93, #00, #fd, #3f, #c0, #fc, #02, #00, #a1, #00, #ec

#81ba

#1a3a

16

        db #3f, #c0, #fc, #03, #00, #21, #00, #c6, #3f, #c0, #fc, #03, #00, #63, #00, #82

#81ca

#1a4a

16

        db #3f, #c0, #fc, #02, #00, #7e, #00, #c2, #3f, #40, #fc, #02, #00, #7c, #00, #46

#81da

#1a5a

16

        db #7f, #80, #fc, #02, #00, #7e, #00, #fc, #7f, #80, #fe, #01, #00, #73, #00, #fd

#81ea

#1a6a

16

        db #ff, #00, #fe, #01, #00, #20, #00, #f9, #ff, #00, #fe, #01, #00, #30, #01, #fa

#81fa

#1a7a

16

        db #ff, #00, #ff, #00, #00, #98, #01, #f2, #ff, #00, #ff, #00, #00, #c7, #03, #c4

#820a

#1a8a

16

        db #ff, #00, #ff, #00, #c0, #30, #03, #0c, #ff, #00, #ff, #00, #f0, #0c, #0f, #70

#821a

#1a9a

10

        db #ff, #00, #ff, #00, #fc, #03, #7f, #80, #ff, #00

#8224

#1aa4

    L8224_iso_graphic_32:  ;

#8224

#1aa4

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8234

#1ab4

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8244

#1ac4

16

        db #ff, #00, #9f, #60, #ff, #00, #ff, #00, #87, #58, #ff, #00, #ff, #00, #01, #c6

#8254

#1ad4

16

        db #ff, #00, #ff, #00, #00, #d9, #7f, #80, #fe, #01, #00, #5e, #1f, #60, #fe, #01

#8264

#1ae4

16

        db #00, #e7, #1f, #a0, #fc, #02, #00, #99, #1f, #a0, #fc, #03, #00, #06, #1f, #20

#8274

#1af4

16

        db #f8, #05, #00, #01, #1f, #a0, #f8, #06, #00, #00, #1f, #60, #f0, #0a, #00, #18

#8284

#1b04

16

        db #3f, #40, #f0, #0c, #00, #3c, #3f, #40, #f0, #0c, #00, #7c, #7f, #80, #f0, #08

#8294

#1b14

16

        db #00, #6c, #7f, #80, #f0, #0c, #00, #5f, #ff, #00, #fc, #03, #00, #7d, #7f, #80

#82a4

#1b24

16

        db #ff, #00, #01, #fa, #ff, #00, #ff, #00, #81, #72, #ff, #00, #ff, #00, #e3, #1c

#82b4

#1b34

2

        db #ff, #00

#82b6

#1b36

    L82b6_iso_graphic_33:  ;

#82b6

#1b36

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#82c6

#1b46

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#82d6

#1b56

16

        db #ff, #00, #f9, #06, #ff, #00, #ff, #00, #f8, #05, #7f, #80, #ff, #00, #f0, #0c

#82e6

#1b66

16

        db #1f, #60, #ff, #00, #f0, #0d, #07, #98, #ff, #00, #e0, #15, #01, #e6, #ff, #00

#82f6

#1b76

16

        db #e0, #1e, #01, #7a, #ff, #00, #c0, #29, #01, #9a, #ff, #00, #c0, #30, #01, #62

#8306

#1b86

16

        db #ff, #00, #80, #50, #01, #1a, #ff, #00, #80, #60, #01, #06, #ff, #00, #00, #a1

#8316

#1b96

16

        db #03, #84, #ff, #00, #00, #c3, #03, #c4, #ff, #00, #00, #c7, #07, #c8, #ff, #00

#8326

#1ba6

16

        db #00, #86, #07, #c8, #ff, #00, #00, #c5, #0f, #f0, #ff, #00, #c0, #37, #07, #d8

#8336

#1bb6

16

        db #ff, #00, #f0, #0f, #1f, #a0, #ff, #00, #f8, #07, #1f, #20, #ff, #00, #fe, #01

#8346

#1bc6

2

        db #3f, #c0

#8348

#1bc8

    L8348_iso_graphic_34:  ;

#8348

#1bc8

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8358

#1bd8

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8368

#1be8

16

        db #ff, #00, #9f, #60, #ff, #00, #ff, #00, #87, #58, #ff, #00, #ff, #00, #01, #c6

#8378

#1bf8

16

        db #ff, #00, #ff, #00, #00, #d9, #7f, #80, #fe, #01, #00, #5e, #1f, #60, #fe, #01

#8388

#1c08

16

        db #00, #e7, #1f, #a0, #fc, #02, #00, #99, #1f, #a0, #fc, #03, #00, #06, #1f, #20

#8398

#1c18

16

        db #f8, #05, #00, #01, #1f, #a0, #f8, #06, #00, #00, #1f, #60, #f0, #0a, #00, #18

#83a8

#1c28

16

        db #3f, #40, #f0, #0c, #00, #2c, #3f, #40, #f0, #0d, #00, #8e, #7f, #80, #f0, #08

#83b8

#1c38

16

        db #00, #6e, #7f, #80, #f0, #0c, #00, #1f, #ff, #00, #fc, #03, #00, #4d, #ff, #00

#83c8

#1c48

16

        db #ff, #00, #01, #de, #ff, #00, #ff, #00, #81, #5a, #ff, #00, #ff, #00, #c3, #34

#83d8

#1c58

2

        db #ff, #00

#83da

#1c5a

    L83da_iso_graphic_35:  ;

#83da

#1c5a

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#83ea

#1c6a

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#83fa

#1c7a

16

        db #ff, #00, #f9, #06, #ff, #00, #ff, #00, #f8, #05, #7f, #80, #ff, #00, #f0, #0c

#840a

#1c8a

16

        db #1f, #60, #ff, #00, #f0, #0d, #07, #98, #ff, #00, #e0, #15, #01, #e6, #ff, #00

#841a

#1c9a

16

        db #e0, #1e, #01, #7a, #ff, #00, #c0, #29, #01, #9a, #ff, #00, #c0, #30, #01, #62

#842a

#1caa

16

        db #ff, #00, #80, #50, #01, #1a, #ff, #00, #80, #60, #01, #06, #ff, #00, #00, #a1

#843a

#1cba

16

        db #03, #84, #ff, #00, #00, #c2, #03, #c4, #ff, #00, #00, #d8, #07, #e8, #ff, #00

#844a

#1cca

16

        db #00, #86, #07, #e8, #ff, #00, #00, #c1, #0f, #f0, #ff, #00, #c0, #34, #0f, #d0

#845a

#1cda

16

        db #ff, #00, #f0, #0d, #1f, #e0, #ff, #00, #f8, #05, #1f, #a0, #ff, #00, #fc, #03

#846a

#1cea

2

        db #3f, #40

#846c

#1cec

    L846c_iso_graphic_36:  ;

#846c

#1cec

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#847c

#1cfc

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#848c

#1d0c

16

        db #ff, #00, #9f, #60, #ff, #00, #ff, #00, #87, #58, #ff, #00, #ff, #00, #01, #c6

#849c

#1d1c

16

        db #ff, #00, #ff, #00, #00, #d9, #7f, #80, #fe, #01, #00, #5e, #1f, #60, #fe, #01

#84ac

#1d2c

16

        db #00, #e7, #1f, #a0, #fc, #02, #00, #99, #1f, #a0, #fc, #03, #00, #06, #1f, #20

#84bc

#1d3c

16

        db #f8, #05, #00, #01, #1f, #a0, #f8, #06, #00, #00, #1f, #60, #f0, #0a, #00, #3c

#84cc

#1d4c

16

        db #3f, #40, #f0, #0c, #00, #64, #3f, #40, #f0, #0c, #00, #ca, #7f, #80, #f0, #08

#84dc

#1d5c

16

        db #00, #da, #7f, #80, #f0, #0c, #00, #d3, #ff, #00, #fc, #03, #00, #c3, #ff, #00

#84ec

#1d6c

16

        db #ff, #00, #01, #e6, #ff, #00, #ff, #00, #c1, #3a, #ff, #00, #ff, #00, #f3, #0c

#84fc

#1d7c

2

        db #ff, #00

#84fe

#1d7e

    L84fe_iso_graphic_37:  ;

#84fe

#1d7e

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#850e

#1d8e

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#851e

#1d9e

16

        db #ff, #00, #f9, #06, #ff, #00, #ff, #00, #f8, #05, #7f, #80, #ff, #00, #f0, #0c

#852e

#1dae

16

        db #1f, #60, #ff, #00, #f0, #0d, #07, #98, #ff, #00, #e0, #15, #01, #e6, #ff, #00

#853e

#1dbe

16

        db #e0, #1e, #01, #7a, #ff, #00, #c0, #29, #01, #9a, #ff, #00, #c0, #30, #01, #62

#854e

#1dce

16

        db #ff, #00, #80, #50, #01, #1a, #ff, #00, #80, #60, #01, #06, #ff, #00, #00, #a3

#855e

#1dde

16

        db #03, #c4, #ff, #00, #00, #c6, #03, #44, #ff, #00, #00, #cc, #07, #a8, #ff, #00

#856e

#1dee

16

        db #00, #8d, #07, #a8, #ff, #00, #00, #cd, #0f, #30, #ff, #00, #c0, #3c, #0f, #30

#857e

#1dfe

16

        db #ff, #00, #f0, #0e, #1f, #60, #ff, #00, #fc, #03, #1f, #a0, #ff, #00, #ff, #00

#858e

#1e0e

2

        db #3f, #c0

#8590

#1e10

    L8590_iso_graphic_38:  ;

#8590

#1e10

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#85a0

#1e20

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#85b0

#1e30

16

        db #ff, #00, #9f, #60, #ff, #00, #ff, #00, #87, #58, #ff, #00, #ff, #00, #01, #c6

#85c0

#1e40

16

        db #ff, #00, #ff, #00, #00, #d9, #7f, #80, #fe, #01, #00, #5e, #1f, #60, #fe, #01

#85d0

#1e50

16

        db #00, #e7, #1f, #a0, #fc, #02, #00, #99, #1f, #a0, #fc, #03, #00, #06, #1f, #20

#85e0

#1e60

16

        db #f8, #05, #00, #01, #1f, #a0, #f8, #06, #00, #1c, #1f, #60, #f0, #0a, #00, #3e

#85f0

#1e70

16

        db #3f, #40, #f0, #0c, #00, #76, #3f, #40, #f0, #0c, #00, #7a, #7f, #80, #f0, #08

#8600

#1e80

16

        db #00, #7e, #7f, #80, #f0, #0c, #00, #7f, #ff, #00, #fc, #03, #00, #3d, #ff, #00

#8610

#1e90

16

        db #ff, #00, #01, #da, #ff, #00, #ff, #00, #81, #72, #ff, #00, #ff, #00, #f3, #0c

#8620

#1ea0

2

        db #ff, #00

#8622

#1ea2

    L8622_iso_graphic_39:  ;

#8622

#1ea2

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8632

#1eb2

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8642

#1ec2

16

        db #ff, #00, #f9, #06, #ff, #00, #ff, #00, #f8, #05, #7f, #80, #ff, #00, #f0, #0c

#8652

#1ed2

16

        db #1f, #60, #ff, #00, #f0, #0d, #07, #98, #ff, #00, #e0, #15, #01, #e6, #ff, #00

#8662

#1ee2

16

        db #e0, #1e, #01, #7a, #ff, #00, #c0, #29, #01, #9a, #ff, #00, #c0, #30, #01, #62

#8672

#1ef2

16

        db #ff, #00, #80, #50, #01, #1a, #ff, #00, #80, #61, #01, #c6, #ff, #00, #00, #a3

#8682

#1f02

16

        db #03, #e4, #ff, #00, #00, #c7, #03, #64, #ff, #00, #00, #c7, #07, #a8, #ff, #00

#8692

#1f12

16

        db #00, #87, #07, #e8, #ff, #00, #00, #c7, #0f, #f0, #ff, #00, #c0, #33, #0f, #d0

#86a2

#1f22

16

        db #ff, #00, #f0, #0d, #1f, #a0, #ff, #00, #f8, #07, #1f, #20, #ff, #00, #ff, #00

#86b2

#1f32

2

        db #3f, #c0

#86b4

#1f34

    L86b4_iso_graphic_40:  ;

#86b4

#1f34

16

        db #0b, #03, #ff, #00, #f7, #08, #ff, #00, #ff, #00, #e3, #1c, #ff, #00, #ff, #00

#86c4

#1f44

16

        db #f7, #08, #ff, #00, #ff, #00, #f7, #08, #ff, #00, #ff, #00, #f1, #0e, #ff, #00

#86d4

#1f54

16

        db #ff, #00, #f0, #09, #3f, #c0, #ff, #00, #f0, #0f, #1f, #20, #ff, #00, #f0, #0f

#86e4

#1f64

16

        db #1f, #e0, #ff, #00, #f0, #09, #1f, #e0, #ff, #00, #f0, #0f, #1f, #20, #ff, #00

#86f4

#1f74

4

        db #fe, #01, #1f, #e0

#86f8

#1f78

    L86f8_iso_graphic_41:  ;

#86f8

#1f78

16

        db #0b, #04, #ff, #00, #ff, #00, #7f, #80, #ff, #00, #ff, #00, #fe, #01, #3f, #c0

#8708

#1f88

16

        db #ff, #00, #ff, #00, #ff, #00, #7f, #80, #ff, #00, #ff, #00, #ff, #00, #7f, #80

#8718

#1f98

16

        db #ff, #00, #ff, #00, #ff, #00, #1f, #e0, #ff, #00, #ff, #00, #ff, #00, #03, #9c

#8728

#1fa8

16

        db #ff, #00, #ff, #00, #ff, #00, #01, #f2, #ff, #00, #ff, #00, #ff, #00, #01, #fe

#8738

#1fb8

16

        db #ff, #00, #ff, #00, #ff, #00, #01, #9e, #ff, #00, #ff, #00, #ff, #00, #01, #f2

#8748

#1fc8

10

        db #ff, #00, #ff, #00, #ff, #00, #e1, #1e, #ff, #00

#8752

#1fd2

    L8752_iso_graphic_42:  ;

#8752

#1fd2

16

        db #0b, #03, #ff, #00, #f7, #08, #ff, #00, #ff, #00, #e3, #1c, #ff, #00, #ff, #00

#8762

#1fe2

16

        db #f7, #08, #ff, #00, #ff, #00, #f7, #08, #ff, #00, #ff, #00, #f1, #0e, #ff, #00

#8772

#1ff2

16

        db #ff, #00, #f0, #0d, #3f, #c0, #ff, #00, #f0, #0a, #1f, #a0, #ff, #00, #f0, #0d

#8782

#2002

16

        db #1f, #60, #ff, #00, #f0, #0a, #1f, #a0, #ff, #00, #f0, #0f, #1f, #60, #ff, #00

#8792

#2012

4

        db #fe, #01, #1f, #e0

#8796

#2016

    L8796_iso_graphic_43:  ;

#8796

#2016

16

        db #0b, #04, #ff, #00, #ff, #00, #7f, #80, #ff, #00, #ff, #00, #fe, #01, #3f, #c0

#87a6

#2026

16

        db #ff, #00, #ff, #00, #ff, #00, #7f, #80, #ff, #00, #ff, #00, #ff, #00, #7f, #80

#87b6

#2036

16

        db #ff, #00, #ff, #00, #ff, #00, #1f, #e0, #ff, #00, #ff, #00, #ff, #00, #03, #dc

#87c6

#2046

16

        db #ff, #00, #ff, #00, #ff, #00, #01, #aa, #ff, #00, #ff, #00, #ff, #00, #01, #d6

#87d6

#2056

16

        db #ff, #00, #ff, #00, #ff, #00, #01, #aa, #ff, #00, #ff, #00, #ff, #00, #01, #f6

#87e6

#2066

10

        db #ff, #00, #ff, #00, #ff, #00, #e1, #1e, #ff, #00

#87f0

#2070

    L87f0_iso_graphic_44:  ;

#87f0

#2070

16

        db #11, #03, #ff, #00, #9f, #60, #ff, #00, #ff, #00, #87, #58, #ff, #00, #ff, #00

#8800

#2080

16

        db #01, #86, #ff, #00, #ff, #00, #00, #b1, #7f, #80, #fe, #01, #00, #38, #1f, #60

#8810

#2090

16

        db #fe, #01, #00, #79, #07, #18, #fc, #02, #00, #71, #07, #c8, #fc, #02, #00, #fb

#8820

#20a0

16

        db #0f, #d0, #f8, #04, #00, #ff, #0f, #90, #f8, #05, #00, #ef, #1f, #a0, #f0, #09

#8830

#20b0

16

        db #00, #c7, #1f, #20, #f0, #0c, #00, #4f, #3f, #40, #fc, #03, #00, #0e, #3f, #40

#8840

#20c0

16

        db #ff, #00, #00, #c6, #7f, #80, #ff, #00, #c0, #30, #7f, #80, #ff, #00, #f0, #0d

#8850

#20d0

8

        db #ff, #00, #ff, #00, #fc, #03, #ff, #00

#8858

#20d8

    L8858_iso_graphic_45:  ;

#8858

#20d8

16

        db #11, #04, #ff, #00, #f9, #06, #ff, #00, #ff, #00, #ff, #00, #f8, #05, #7f, #80

#8868

#20e8

16

        db #ff, #00, #ff, #00, #f0, #08, #1f, #60, #ff, #00, #ff, #00, #f0, #0b, #07, #18

#8878

#20f8

16

        db #ff, #00, #ff, #00, #e0, #13, #01, #86, #ff, #00, #ff, #00, #e0, #17, #00, #91

#8888

#2108

16

        db #7f, #80, #ff, #00, #c0, #27, #00, #1c, #7f, #80, #ff, #00, #c0, #2f, #00, #bd

#8898

#2118

16

        db #ff, #00, #ff, #00, #80, #4f, #00, #f9, #ff, #00, #ff, #00, #80, #5e, #01, #fa

#88a8

#2128

16

        db #ff, #00, #ff, #00, #00, #9c, #01, #72, #ff, #00, #ff, #00, #00, #c4, #03, #f4

#88b8

#2138

16

        db #ff, #00, #ff, #00, #c0, #30, #03, #e4, #ff, #00, #ff, #00, #f0, #0c, #07, #68

#88c8

#2148

16

        db #ff, #00, #ff, #00, #fc, #03, #07, #08, #ff, #00, #ff, #00, #ff, #00, #0f, #d0

#88d8

#2158

10

        db #ff, #00, #ff, #00, #ff, #00, #cf, #30, #ff, #00

#88e2

#2162

    L88e2_iso_graphic_46:  ;

#88e2

#2162

16

        db #10, #02, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#88f2

#2172

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #fc, #03

#8902

#2182

16

        db #3f, #c0, #fe, #01, #1f, #e0, #ff, #00, #0f, #f0, #ff, #00, #ff, #00, #ff, #00

#8912

#2192

16

        db #ff, #00, #ff, #00, #ff, #00, #e1, #1e, #ff, #00, #f0, #0f, #ff, #00, #f8, #07

#8922

#21a2

2

        db #7f, #80

#8924

#21a4

    L8924_iso_graphic_47:  ;

#8924

#21a4

16

        db #10, #02, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8934

#21b4

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8944

#21c4

16

        db #c3, #3c, #ff, #00, #e1, #1e, #ff, #00, #f0, #0f, #ff, #00, #ff, #00, #ff, #00

#8954

#21d4

16

        db #ff, #00, #ff, #00, #ff, #00, #fe, #01, #1f, #e0, #ff, #00, #0f, #f0, #ff, #00

#8964

#21e4

2

        db #87, #78

#8966

#21e6

    L8966_iso_graphic_48:  ;

#8966

#21e6

16

        db #0d, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8976

#21f6

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #f7, #08, #ff, #00

#8986

#2206

16

        db #ff, #00, #e7, #18, #ff, #00, #ff, #00, #c7, #38, #ff, #00, #ff, #00, #c7, #38

#8996

#2216

16

        db #df, #20, #ff, #00, #cf, #30, #9f, #60, #ff, #00, #df, #20, #1f, #e0, #ff, #00

#89a6

#2226

16

        db #ff, #00, #1f, #e0, #ff, #00, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #7f, #80

#89b6

#2236

    L89b6_iso_graphic_49:  ;

#89b6

#2236

16

        db #0d, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#89c6

#2246

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #7f, #80

#89d6

#2256

16

        db #ff, #00, #fe, #01, #7f, #80, #ff, #00, #fc, #03, #7f, #80, #ff, #00, #fc, #03

#89e6

#2266

16

        db #7d, #82, #ff, #00, #fc, #03, #f9, #06, #ff, #00, #fd, #02, #f1, #0e, #ff, #00

#89f6

#2276

16

        db #ff, #00, #f1, #0e, #ff, #00, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #f7, #08

#8a06

#2286

    L8a06_iso_graphic_50:  ;

#8a06

#2286

16

        db #16, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8a16

#2296

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #3f, #c0, #ff, #00

#8a26

#22a6

16

        db #ff, #00, #0f, #f0, #ff, #00, #ff, #00, #c3, #3c, #ff, #00, #ff, #00, #f0, #0f

#8a36

#22b6

16

        db #ff, #00, #ff, #00, #fc, #03, #3f, #c0, #ff, #00, #ff, #00, #0f, #f0, #ff, #00

#8a46

#22c6

16

        db #ff, #00, #c3, #3c, #ff, #00, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00

#8a56

#22d6

16

        db #ff, #00, #ff, #00, #ff, #00, #e7, #18, #ff, #00, #ff, #00, #e1, #1e, #ff, #00

#8a66

#22e6

16

        db #ff, #00, #f8, #07, #7f, #80, #ff, #00, #fe, #01, #1f, #e0, #ff, #00, #ff, #00

#8a76

#22f6

16

        db #87, #78, #ff, #00, #ff, #00, #e1, #1e, #ff, #00, #ff, #00, #f8, #07, #7f, #80

#8a86

#2306

6

        db #ff, #00, #fe, #01, #7f, #80

#8a8c

#230c

    L8a8c_iso_graphic_51:  ;

#8a8c

#230c

16

        db #16, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8a9c

#231c

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8aac

#232c

16

        db #ff, #00, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0f, #ff, #00

#8abc

#233c

16

        db #ff, #00, #ff, #00, #fc, #03, #3f, #c0, #ff, #00, #ff, #00, #ff, #00, #0f, #f0

#8acc

#234c

16

        db #ff, #00, #ff, #00, #ff, #00, #c3, #3c, #ff, #00, #ff, #00, #ff, #00, #f0, #0f

#8adc

#235c

16

        db #ff, #00, #ff, #00, #ff, #00, #fc, #03, #3f, #c0, #ff, #00, #ff, #00, #ff, #00

#8aec

#236c

16

        db #3f, #c0, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8afc

#237c

16

        db #ff, #00, #fe, #01, #7f, #80, #ff, #00, #ff, #00, #fe, #01, #1f, #e0, #ff, #00

#8b0c

#238c

16

        db #ff, #00, #ff, #00, #87, #78, #ff, #00, #ff, #00, #ff, #00, #e1, #1e, #ff, #00

#8b1c

#239c

16

        db #ff, #00, #ff, #00, #f8, #07, #7f, #80, #ff, #00, #ff, #00, #fe, #01, #1f, #e0

#8b2c

#23ac

16

        db #ff, #00, #ff, #00, #ff, #00, #87, #78, #ff, #00, #ff, #00, #ff, #00, #e7, #18

#8b3c

#23bc

2

        db #ff, #00

#8b3e

#23be

    L8b3e_iso_graphic_52:  ;

#8b3e

#23be

16

        db #16, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8b4e

#23ce

16

        db #ff, #00, #ff, #00, #ff, #00, #cf, #30, #ff, #00, #ff, #00, #cf, #30, #ff, #00

#8b5e

#23de

16

        db #ff, #00, #9f, #60, #ff, #00, #ff, #00, #9f, #60, #ff, #00, #ff, #00, #3f, #c0

#8b6e

#23ee

16

        db #ff, #00, #ff, #00, #3f, #c0, #f3, #0c, #fe, #01, #7f, #80, #f3, #0c, #fe, #01

#8b7e

#23fe

16

        db #7f, #80, #e7, #18, #fc, #03, #ff, #00, #e7, #18, #fc, #03, #ff, #00, #cf, #30

#8b8e

#240e

16

        db #f9, #06, #ff, #00, #cf, #30, #f9, #06, #ff, #00, #9f, #60, #f3, #0c, #ff, #00

#8b9e

#241e

16

        db #9f, #60, #f3, #0c, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #3f, #c0, #ff, #00

#8bae

#242e

16

        db #fe, #01, #7f, #80, #ff, #00, #fe, #01, #7f, #80, #ff, #00, #fc, #03, #ff, #00

#8bbe

#243e

6

        db #ff, #00, #fc, #03, #ff, #00

#8bc4

#2444

    L8bc4_iso_graphic_53:  ;

#8bc4

#2444

16

        db #16, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8bd4

#2454

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #fc, #03, #ff, #00

#8be4

#2464

16

        db #ff, #00, #ff, #00, #fc, #03, #ff, #00, #ff, #00, #ff, #00, #f9, #06, #ff, #00

#8bf4

#2474

16

        db #ff, #00, #ff, #00, #f9, #06, #ff, #00, #ff, #00, #ff, #00, #f3, #0c, #ff, #00

#8c04

#2484

16

        db #ff, #00, #ff, #00, #f3, #0c, #ff, #00, #3f, #c0, #ff, #00, #e7, #18, #ff, #00

#8c14

#2494

16

        db #3f, #c0, #ff, #00, #e7, #18, #fe, #01, #7f, #80, #ff, #00, #cf, #30, #fe, #01

#8c24

#24a4

16

        db #7f, #80, #ff, #00, #cf, #30, #fc, #03, #ff, #00, #ff, #00, #9f, #60, #fc, #03

#8c34

#24b4

16

        db #ff, #00, #ff, #00, #9f, #60, #f9, #06, #ff, #00, #ff, #00, #3f, #c0, #f9, #06

#8c44

#24c4

16

        db #ff, #00, #ff, #00, #3f, #c0, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f3, #0c

#8c54

#24d4

16

        db #ff, #00, #ff, #00, #ff, #00, #e7, #18, #ff, #00, #ff, #00, #ff, #00, #e7, #18

#8c64

#24e4

16

        db #ff, #00, #ff, #00, #ff, #00, #cf, #30, #ff, #00, #ff, #00, #ff, #00, #cf, #30

#8c74

#24f4

2

        db #ff, #00

#8c76

#24f6

    L8c76_iso_graphic_54:  ;

#8c76

#24f6

16

        db #11, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8c86

#2506

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8c96

#2516

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #fe, #01, #ff, #00

#8ca6

#2526

16

        db #ff, #00, #fb, #04, #bf, #40, #ff, #00, #fd, #02, #ef, #10, #ff, #00, #ff, #00

#8cb6

#2536

16

        db #3b, #c4, #ff, #00, #fd, #02, #de, #21, #ff, #00, #ff, #00, #73, #8c, #bf, #40

#8cc6

#2546

16

        db #ff, #00, #dd, #22, #ef, #10, #ff, #00, #f7, #08, #3f, #c0, #ff, #00, #fd, #02

#8cd6

#2556

8

        db #df, #20, #ff, #00, #ff, #00, #7f, #80

#8cde

#255e

    L8cde_iso_graphic_55:  ;

#8cde

#255e

16

        db #11, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8cee

#256e

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8cfe

#257e

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ef, #10

#8d0e

#258e

16

        db #ff, #00, #ff, #00, #bb, #44, #ff, #00, #ff, #00, #de, #21, #ff, #00, #ff, #00

#8d1e

#259e

16

        db #f3, #0c, #bf, #40, #ff, #00, #dd, #22, #ef, #10, #ff, #00, #f7, #08, #3b, #c4

#8d2e

#25ae

16

        db #ff, #00, #fd, #02, #de, #21, #ff, #00, #ff, #00, #73, #8c, #ff, #00, #ff, #00

#8d3e

#25be

8

        db #dd, #22, #ff, #00, #ff, #00, #f7, #08

#8d46

#25c6

    L8d46_iso_graphic_56:  ;

#8d46

#25c6

16

        db #14, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8d56

#25d6

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8d66

#25e6

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #fa, #05, #ff, #00, #ff, #00, #fe, #01

#8d76

#25f6

16

        db #bf, #40, #ff, #00, #f5, #0a, #ff, #00, #ff, #00, #ff, #00, #7f, #80, #ff, #00

#8d86

#2606

16

        db #eb, #14, #ff, #00, #ff, #00, #fa, #05, #ff, #00, #ff, #00, #d7, #28, #ff, #00

#8d96

#2616

16

        db #ff, #00, #fd, #02, #ff, #00, #ff, #00, #af, #50, #ff, #00, #ff, #00, #eb, #14

#8da6

#2626

16

        db #ff, #00, #ff, #00, #5f, #a0, #ff, #00, #ff, #00, #f7, #08, #ff, #00, #fe, #01

#8db6

#2636

10

        db #bf, #40, #ff, #00, #ff, #00, #af, #50, #ff, #00

#8dc0

#2640

    L8dc0_iso_graphic_57:  ;

#8dc0

#2640

16

        db #14, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8dd0

#2650

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#8de0

#2660

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #af, #50, #ff, #00, #ff, #00

#8df0

#2670

16

        db #eb, #14, #ff, #00, #ff, #00, #5f, #a0, #ff, #00, #ff, #00, #f7, #08, #ff, #00

#8e00

#2680

16

        db #fe, #01, #bf, #40, #ff, #00, #ff, #00, #af, #50, #ff, #00, #fd, #02, #7f, #80

#8e10

#2690

16

        db #ff, #00, #ff, #00, #df, #20, #ff, #00, #fa, #05, #ff, #00, #ff, #00, #fe, #01

#8e20

#26a0

16

        db #bf, #40, #ff, #00, #f5, #0a, #ff, #00, #ff, #00, #ff, #00, #7f, #80, #ff, #00

#8e30

#26b0

10

        db #eb, #14, #ff, #00, #ff, #00, #fa, #05, #ff, #00

#8e3a

#26ba

#8e3a

#26ba

#8e3a

#26ba

    L8e3a_iso_additional_graphic_0:  ;

#8e3a

#26ba

16

        db #1e, #04, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #ff, #00, #0f, #b0, #ff, #00

#8e4a

#26ca

16

        db #ff, #00, #fe, #01, #03, #8c, #ff, #00, #ff, #00, #fe, #01, #01, #a2, #ff, #00

#8e5a

#26da

16

        db #ff, #00, #fc, #03, #01, #8a, #ff, #00, #ff, #00, #fc, #03, #00, #c3, #cf, #30

#8e6a

#26ea

16

        db #ff, #00, #f8, #07, #00, #32, #43, #ac, #ff, #00, #f8, #07, #00, #0e, #00, #63

#8e7a

#26fa

16

        db #ff, #00, #f8, #06, #00, #02, #00, #68, #7f, #80, #f8, #06, #00, #04, #00, #62

#8e8a

#270a

16

        db #7f, #80, #e0, #1c, #00, #06, #00, #70, #7f, #80, #e0, #16, #00, #31, #00, #cc

#8e9a

#271a

16

        db #7f, #80, #c0, #37, #00, #2c, #00, #43, #7f, #80, #c0, #37, #00, #73, #00, #00

#8eaa

#272a

16

        db #7f, #80, #80, #76, #00, #4c, #00, #c1, #ff, #00, #80, #7e, #00, #c3, #00, #21

#8eba

#273a

16

        db #ff, #00, #00, #e4, #00, #80, #01, #e2, #ff, #00, #00, #e1, #00, #80, #01, #32

#8eca

#274a

16

        db #ff, #00, #00, #c1, #00, #08, #03, #5c, #ff, #00, #00, #c3, #00, #1c, #0b, #74

#8eda

#275a

16

        db #ff, #00, #00, #82, #00, #08, #0f, #b0, #ff, #00, #00, #c3, #00, #08, #0f, #d0

#8eea

#276a

16

        db #ff, #00, #c0, #31, #00, #c9, #0f, #70, #ff, #00, #f1, #0e, #c0, #29, #0f, #10

#8efa

#277a

16

        db #ff, #00, #fd, #02, #c0, #2a, #1f, #20, #ff, #00, #ff, #00, #c0, #2a, #1f, #20

#8f0a

#278a

16

        db #ff, #00, #ff, #00, #c0, #28, #3f, #40, #ff, #00, #ff, #00, #e0, #08, #3f, #40

#8f1a

#279a

16

        db #ff, #00, #ff, #00, #e0, #0b, #7f, #80, #ff, #00, #ff, #00, #e3, #08, #7f, #80

#8f2a

#27aa

2

        db #ff, #00

#8f2c

#27ac

    L8f2c_iso_additional_graphic_1:  ;

#8f2c

#27ac

16

        db #1e, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0b, #ff, #00

#8f3c

#27bc

16

        db #ff, #00, #ff, #00, #e0, #18, #3f, #c0, #ff, #00, #ff, #00, #e0, #1a, #1f, #20

#8f4c

#27cc

16

        db #ff, #00, #ff, #00, #c0, #38, #1f, #a0, #ff, #00, #ff, #00, #c0, #3c, #0c, #33

#8f5c

#27dc

16

        db #ff, #00, #ff, #00, #80, #73, #04, #2a, #3f, #c0, #ff, #00, #80, #70, #00, #e6

#8f6c

#27ec

16

        db #0f, #30, #ff, #00, #80, #60, #00, #26, #07, #88, #ff, #00, #80, #60, #00, #46

#8f7c

#27fc

16

        db #07, #28, #fe, #01, #00, #c0, #00, #67, #07, #08, #fe, #01, #00, #63, #00, #1c

#8f8c

#280c

16

        db #07, #c8, #fc, #03, #00, #72, #00, #c4, #07, #38, #fc, #03, #00, #77, #00, #30

#8f9c

#281c

16

        db #07, #08, #f8, #07, #00, #64, #00, #cc, #0f, #10, #f8, #07, #00, #ec, #00, #32

#8fac

#282c

16

        db #0f, #10, #f0, #0e, #00, #48, #00, #0e, #1f, #20, #f0, #0e, #00, #18, #00, #03

#8fbc

#283c

16

        db #1f, #20, #f0, #0c, #00, #10, #00, #85, #3f, #c0, #f0, #0c, #00, #31, #00, #c7

#8fcc

#284c

16

        db #bf, #40, #f0, #08, #00, #20, #00, #8b, #ff, #00, #f0, #0c, #00, #30, #00, #8d

#8fdc

#285c

16

        db #ff, #00, #fc, #03, #00, #1c, #00, #97, #ff, #00, #ff, #00, #1c, #e2, #00, #91

#8fec

#286c

16

        db #ff, #00, #ff, #00, #dc, #22, #01, #a2, #ff, #00, #ff, #00, #fc, #02, #01, #a2

#8ffc

#287c

16

        db #ff, #00, #ff, #00, #fc, #02, #03, #84, #ff, #00, #ff, #00, #fe, #00, #03, #84

#900c

#288c

16

        db #ff, #00, #ff, #00, #fe, #00, #07, #b8, #ff, #00, #ff, #00, #fe, #00, #37, #88

#901c

#289c

2

        db #ff, #00

#901e

#289e

    L901e_iso_additional_graphic_2:  ;

#901e

#289e

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #bf, #40, #ff, #00, #ff, #00

#902e

#28ae

16

        db #0f, #f0, #ff, #00, #ff, #00, #03, #fc, #ff, #00, #fe, #01, #03, #fc, #ff, #00

#903e

#28be

16

        db #fe, #01, #03, #fc, #ff, #00, #fc, #03, #01, #fe, #ef, #10, #fe, #01, #00, #ff

#904e

#28ce

16

        db #43, #bc, #ff, #00, #00, #ff, #00, #ff, #ff, #00, #00, #ff, #00, #ff, #f6, #09

#905e

#28de

16

        db #00, #ff, #01, #fe, #f2, #0d, #00, #ff, #01, #fe, #e0, #1f, #00, #ff, #03, #fc

#906e

#28ee

16

        db #e0, #1f, #00, #ff, #13, #ec, #c0, #3f, #00, #ff, #3f, #c0, #c0, #3f, #00, #ff

#907e

#28fe

16

        db #3f, #c0, #c0, #3f, #00, #ff, #7f, #80, #f0, #0f, #80, #7f, #3f, #c0, #fd, #02

#908e

#290e

16

        db #e0, #1f, #1f, #e0, #ff, #00, #f0, #0f, #1f, #e0, #ff, #00, #f0, #0f, #3f, #c0

#909e

#291e

16

        db #ff, #00, #f0, #0f, #3f, #c0, #ff, #00, #fc, #03, #7f, #80, #ff, #00, #ff, #00

#90ae

#292e

2

        db #7f, #80

#90b0

#2930

    L90b0_iso_additional_graphic_3:  ;

#90b0

#2930

16

        db #18, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #fb, #04, #ff, #00

#90c0

#2940

16

        db #ff, #00, #ff, #00, #f0, #0f, #ff, #00, #ff, #00, #ff, #00, #f0, #0f, #3f, #c0

#90d0

#2950

16

        db #ff, #00, #ff, #00, #e0, #1f, #3f, #c0, #ff, #00, #ff, #00, #e0, #1f, #3f, #c0

#90e0

#2960

16

        db #ff, #00, #ff, #00, #c0, #3f, #1e, #e1, #ff, #00, #ff, #00, #e0, #1f, #04, #fb

#90f0

#2970

16

        db #3f, #c0, #ff, #00, #f0, #0f, #00, #ff, #0f, #f0, #ff, #00, #f0, #0f, #00, #ff

#9100

#2980

16

        db #0f, #f0, #ff, #00, #60, #9f, #00, #ff, #1f, #e0, #ff, #00, #20, #df, #00, #ff

#9110

#2990

16

        db #1f, #e0, #fe, #01, #00, #ff, #00, #ff, #3f, #c0, #fe, #01, #00, #ff, #01, #fe

#9120

#29a0

16

        db #3f, #c0, #fc, #03, #00, #ff, #03, #fc, #ff, #00, #fc, #03, #00, #ff, #03, #fc

#9130

#29b0

16

        db #ff, #00, #fc, #03, #00, #ff, #07, #f8, #ff, #00, #ff, #00, #08, #f7, #03, #fc

#9140

#29c0

16

        db #ff, #00, #ff, #00, #de, #21, #01, #fe, #ff, #00, #ff, #00, #ff, #00, #01, #fe

#9150

#29d0

16

        db #ff, #00, #ff, #00, #ff, #00, #03, #fc, #ff, #00, #ff, #00, #ff, #00, #03, #fc

#9160

#29e0

16

        db #ff, #00, #ff, #00, #ff, #00, #c7, #38, #ff, #00, #ff, #00, #ff, #00, #f7, #08

#9170

#29f0

2

        db #ff, #00

#9172

#29f2

    L9172_iso_additional_graphic_4:  ;

#9172

#29f2

16

        db #15, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9182

#2a02

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #fe, #01, #bc, #43, #ff, #00

#9192

#2a12

16

        db #ff, #00, #7d, #82, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#91a2

#2a22

16

        db #ff, #00, #ff, #00, #ff, #00, #1f, #e0, #ff, #00, #f7, #08, #bf, #40, #fe, #01

#91b2

#2a32

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #f7, #08

#91c2

#2a42

16

        db #ff, #00, #ff, #00, #bf, #40, #ff, #00, #b7, #48, #ff, #00, #ff, #00, #cf, #30

#91d2

#2a52

16

        db #ff, #00, #f9, #06, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#91e2

#2a62

16

        db #fc, #03, #ff, #00, #ff, #00, #cf, #30, #ff, #00, #ff, #00, #ef, #10, #ff, #00

#91f2

#2a72

    L91f2_iso_additional_graphic_5:  ;

#91f2

#2a72

16

        db #16, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9202

#2a82

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #3f, #c0, #ff, #00

#9212

#2a92

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #fe, #01, #ff, #00, #ff, #00, #ff, #00

#9222

#2aa2

16

        db #ff, #00, #ff, #00, #97, #68, #d7, #28, #ff, #00, #cf, #30, #e7, #18, #fd, #02

#9232

#2ab2

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9242

#2ac2

16

        db #ff, #00, #ff, #00, #1f, #e0, #ff, #00, #cf, #30, #bf, #40, #ff, #00, #ff, #00

#9252

#2ad2

16

        db #ff, #00, #f4, #0b, #ff, #00, #ff, #00, #fd, #02, #f9, #06, #7f, #80, #ff, #00

#9262

#2ae2

16

        db #fd, #02, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9272

#2af2

6

        db #ff, #00, #f7, #08, #ff, #00

#9278

#2af8

    L9278_iso_additional_graphic_6:  ;

#9278

#2af8

16

        db #15, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9288

#2b08

16

        db #9f, #60, #ff, #00, #ff, #00, #bf, #40, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9298

#2b18

16

        db #ff, #00, #ff, #00, #bf, #40, #ff, #00, #cf, #30, #ff, #00, #ff, #00, #ff, #00

#92a8

#2b28

16

        db #ff, #00, #ff, #00, #fa, #05, #ff, #00, #f7, #08, #f9, #06, #f7, #08, #fe, #01

#92b8

#2b38

16

        db #bf, #40, #ff, #00, #ff, #00, #7f, #80, #ff, #00, #ff, #00, #ff, #00, #bf, #40

#92c8

#2b48

16

        db #f9, #06, #f5, #0a, #ff, #00, #fd, #02, #f9, #06, #ff, #00, #ff, #00, #ff, #00

#92d8

#2b58

16

        db #ff, #00, #ff, #00, #ff, #00, #cf, #30, #f7, #08, #bf, #40, #ff, #00, #ff, #00

#92e8

#2b68

16

        db #ff, #00, #ff, #00, #ff, #00, #fb, #04, #7f, #80, #ff, #00, #fc, #03, #ff, #00

#92f8

#2b78

    L92f8_iso_additional_graphic_7:  ;

#92f8

#2b78

16

        db #14, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9308

#2b88

16

        db #ff, #00, #ff, #00, #ff, #00, #f7, #08, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9318

#2b98

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #9f, #60, #ff, #00, #f8, #07, #fe, #01

#9328

#2ba8

16

        db #7f, #80, #fd, #02, #fe, #01, #f7, #08, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9338

#2bb8

16

        db #ff, #00, #ff, #00, #ff, #00, #d7, #28, #ff, #00, #fd, #02, #ef, #10, #9f, #60

#9348

#2bc8

16

        db #ff, #00, #ff, #00, #df, #20, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9358

#2bd8

16

        db #ff, #00, #fc, #03, #7f, #80, #ff, #00, #fe, #01, #f7, #08, #ff, #00, #ff, #00

#9368

#2be8

10

        db #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #7f, #80

#9372

#2bf2

    L9372_iso_additional_graphic_8:  ;

#9372

#2bf2

16

        db #19, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #3f, #00, #ff, #00, #ff, #00

#9382

#2c02

16

        db #0f, #00, #ff, #00, #fe, #00, #03, #00, #ff, #00, #fe, #00, #00, #44, #ff, #00

#9392

#2c12

16

        db #fe, #00, #00, #48, #7f, #80, #fe, #01, #00, #21, #6f, #00, #fe, #01, #00, #02

#93a2

#2c22

16

        db #07, #10, #fe, #01, #00, #12, #03, #20, #ff, #00, #00, #a4, #03, #a4, #ff, #00

#93b2

#2c32

16

        db #00, #88, #07, #88, #e3, #08, #80, #4a, #0f, #50, #e0, #05, #c2, #31, #5f, #a0

#93c2

#2c42

16

        db #c1, #12, #c3, #04, #c7, #00, #81, #48, #c0, #29, #c7, #28, #80, #51, #81, #12

#93d2

#2c52

16

        db #ef, #10, #c1, #26, #01, #4c, #ff, #00, #c7, #28, #00, #80, #3f, #40, #ef, #10

#93e2

#2c62

16

        db #80, #48, #3f, #80, #ff, #00, #c0, #25, #1f, #20, #ff, #00, #e0, #11, #3f, #40

#93f2

#2c72

16

        db #ff, #00, #e0, #12, #3f, #40, #ff, #00, #f0, #08, #7f, #80, #ff, #00, #f0, #0b

#9402

#2c82

8

        db #ff, #00, #ff, #00, #fb, #04, #ff, #00

#940a

#2c8a

    L940a_iso_additional_graphic_9:  ;

#940a

#2c8a

16

        db #1a, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#941a

#2c9a

16

        db #ff, #00, #ff, #00, #ff, #00, #df, #00, #ff, #00, #ff, #00, #83, #20, #ff, #00

#942a

#2caa

16

        db #ff, #00, #80, #10, #ff, #00, #ff, #00, #00, #11, #1f, #00, #ff, #00, #00, #52

#943a

#2cba

16

        db #07, #08, #f8, #01, #00, #28, #0f, #10, #f0, #00, #00, #84, #1f, #60, #f0, #0a

#944a

#2cca

16

        db #00, #83, #1f, #80, #f8, #04, #00, #4c, #1f, #20, #fc, #00, #00, #30, #0f, #c0

#945a

#2cda

16

        db #c8, #02, #00, #03, #07, #08, #c0, #21, #00, #84, #07, #50, #e0, #10, #00, #78

#946a

#2cea

16

        db #0f, #20, #e0, #14, #00, #01, #0f, #00, #f0, #09, #00, #06, #1f, #20, #f0, #08

#947a

#2cfa

16

        db #00, #a8, #1f, #a0, #f0, #08, #00, #90, #3f, #40, #f8, #04, #00, #51, #ff, #00

#948a

#2d0a

16

        db #f8, #05, #01, #22, #ff, #00, #f8, #05, #03, #04, #ff, #00, #f8, #04, #03, #84

#949a

#2d1a

14

        db #ff, #00, #fc, #03, #87, #68, #ff, #00, #ff, #00, #ef, #10, #ff, #00

#94a8

#2d28

    L94a8_iso_additional_graphic_10:  ;

#94a8

#2d28

16

        db #17, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#94b8

#2d38

16

        db #0f, #90, #ff, #00, #ff, #00, #03, #48, #ff, #00, #fe, #00, #00, #48, #ff, #00

#94c8

#2d48

16

        db #fc, #02, #00, #48, #3f, #80, #fc, #01, #00, #21, #1f, #20, #f8, #05, #00, #20

#94d8

#2d58

16

        db #1f, #40, #f8, #04, #00, #21, #0f, #80, #fc, #02, #00, #12, #07, #08, #fc, #02

#94e8

#2d68

16

        db #00, #4c, #00, #31, #fe, #01, #00, #22, #01, #42, #e4, #10, #00, #c5, #03, #8c

#94f8

#2d78

16

        db #f0, #0a, #00, #03, #07, #10, #f0, #09, #00, #29, #03, #04, #f8, #06, #00, #49

#9508

#2d88

16

        db #07, #18, #fc, #02, #00, #45, #0f, #60, #fe, #01, #00, #92, #1f, #80, #fe, #01

#9518

#2d98

16

        db #00, #08, #1f, #20, #fe, #01, #00, #23, #3f, #40, #ff, #00, #03, #ac, #7f, #80

#9528

#2da8

12

        db #ff, #00, #8f, #50, #ff, #00, #ff, #00, #9f, #60, #ff, #00

#9534

#2db4

    L9534_iso_additional_graphic_11:  ;

#9534

#2db4

16

        db #18, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #cf, #10, #ff, #00, #ff, #00

#9544

#2dc4

16

        db #87, #28, #ff, #00, #ff, #00, #e0, #19, #ff, #00, #ff, #00, #b9, #06, #ff, #00

#9554

#2dd4

16

        db #fc, #00, #07, #90, #8f, #40, #fc, #00, #03, #50, #c3, #24, #f8, #04, #01, #42

#9564

#2de4

16

        db #c0, #29, #f8, #03, #00, #44, #c1, #22, #f0, #00, #00, #a4, #63, #94, #f0, #06

#9574

#2df4

16

        db #00, #61, #e3, #14, #fe, #01, #00, #11, #f7, #08, #df, #20, #01, #92, #ff, #00

#9584

#2e04

16

        db #c1, #12, #83, #74, #83, #44, #80, #49, #e7, #18, #07, #28, #c0, #28, #fe, #01

#9594

#2e14

16

        db #07, #28, #c0, #24, #0f, #20, #0f, #90, #c0, #24, #03, #c4, #8f, #50, #e0, #11

#95a4

#2e24

16

        db #07, #18, #9f, #20, #e0, #10, #1a, #20, #3f, #80, #f0, #08, #30, #c3, #1f, #20

#95b4

#2e34

16

        db #f0, #09, #f0, #09, #3f, #40, #f9, #06, #f8, #04, #3f, #40, #ff, #00, #fc, #03

#95c4

#2e44

2

        db #7f, #80

#95c6

#2e46

    L95c6_iso_additional_graphic_12:  ;

#95c6

#2e46

16

        db #14, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#95d6

#2e56

16

        db #f3, #0c, #ff, #00, #ff, #00, #f0, #0f, #ff, #00, #ff, #00, #f0, #0f, #3f, #c0

#95e6

#2e66

16

        db #ff, #00, #e0, #1f, #2f, #d0, #ff, #00, #c0, #3f, #27, #d8, #ff, #00, #c0, #3f

#95f6

#2e76

16

        db #2f, #d0, #ff, #00, #c0, #3f, #af, #50, #ff, #00, #c0, #3f, #9f, #60, #ff, #00

#9606

#2e86

16

        db #80, #7f, #9f, #60, #ff, #00, #82, #7d, #bf, #40, #ff, #00, #82, #7d, #7f, #80

#9616

#2e96

16

        db #ff, #00, #02, #fd, #7f, #80, #ff, #00, #2a, #d5, #ff, #00, #ff, #00, #29, #d6

#9626

#2ea6

16

        db #ff, #00, #ff, #00, #29, #d6, #ff, #00, #ff, #00, #ab, #54, #ff, #00, #ff, #00

#9636

#2eb6

10

        db #c3, #3c, #ff, #00, #ff, #00, #ef, #10, #ff, #00

#9640

#2ec0

    L9640_iso_additional_graphic_13:  ;

#9640

#2ec0

16

        db #15, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9650

#2ed0

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9660

#2ee0

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9670

#2ef0

16

        db #ff, #00, #ff, #00, #f8, #07, #7f, #80, #ff, #00, #ff, #00, #f0, #0f, #1f, #e0

#9680

#2f00

16

        db #ff, #00, #ff, #00, #e0, #1f, #07, #f8, #ff, #00, #ff, #00, #e0, #1f, #03, #fc

#9690

#2f10

16

        db #ff, #00, #ff, #00, #c8, #37, #00, #ff, #ff, #00, #ff, #00, #a8, #57, #00, #ff

#96a0

#2f20

16

        db #3f, #c0, #ff, #00, #aa, #55, #00, #ff, #1f, #e0, #ff, #00, #ca, #35, #00, #ff

#96b0

#2f30

16

        db #1f, #e0, #ff, #00, #f2, #0d, #40, #bf, #3f, #c0, #ff, #00, #fa, #05, #48, #b7

#96c0

#2f40

16

        db #3f, #c0, #ff, #00, #fc, #03, #4a, #b5, #7f, #80, #ff, #00, #ff, #00, #4a, #b5

#96d0

#2f50

16

        db #7f, #80, #ff, #00, #ff, #00, #8a, #75, #ff, #00, #ff, #00, #ff, #00, #f2, #0d

#96e0

#2f60

10

        db #ff, #00, #ff, #00, #ff, #00, #fd, #02, #ff, #00

#96ea

#2f6a

    L96ea_iso_additional_graphic_14:  ;

#96ea

#2f6a

16

        db #17, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#96fa

#2f7a

16

        db #f3, #0c, #ff, #00, #ff, #00, #f0, #0f, #ff, #00, #ff, #00, #f0, #0f, #3f, #c0

#970a

#2f8a

16

        db #ff, #00, #e0, #1f, #2f, #d0, #ff, #00, #c0, #3f, #27, #d8, #ff, #00, #80, #7f

#971a

#2f9a

16

        db #2f, #d0, #ff, #00, #80, #7f, #2f, #d0, #ff, #00, #00, #ff, #1f, #e0, #ff, #00

#972a

#2faa

16

        db #00, #ff, #3f, #c0, #ff, #00, #00, #ff, #bf, #40, #ff, #00, #00, #ff, #bf, #40

#973a

#2fba

16

        db #fe, #01, #02, #fd, #bf, #40, #fc, #03, #02, #fd, #bf, #40, #fc, #03, #02, #fd

#974a

#2fca

16

        db #7f, #80, #f8, #07, #02, #fd, #ff, #00, #f8, #07, #09, #f6, #ff, #00, #f0, #0f

#975a

#2fda

16

        db #09, #f6, #ff, #00, #fc, #03, #09, #f6, #ff, #00, #ff, #00, #0b, #f4, #ff, #00

#976a

#2fea

12

        db #ff, #00, #c7, #38, #ff, #00, #ff, #00, #f7, #08, #ff, #00

#9776

#2ff6

    L9776_iso_additional_graphic_15:  ;

#9776

#2ff6

16

        db #15, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9786

#3006

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9796

#3016

16

        db #ff, #00, #ff, #00, #cf, #30, #ff, #00, #ff, #00, #ff, #00, #c3, #3c, #ff, #00

#97a6

#3026

16

        db #ff, #00, #ff, #00, #81, #7e, #ff, #00, #ff, #00, #ff, #00, #80, #7f, #1f, #e0

#97b6

#3036

16

        db #ff, #00, #ff, #00, #00, #ff, #07, #f8, #ff, #00, #ff, #00, #00, #ff, #01, #fe

#97c6

#3046

16

        db #ff, #00, #fe, #01, #40, #bf, #00, #ff, #ff, #00, #fe, #01, #50, #af, #00, #ff

#97d6

#3056

16

        db #7f, #80, #fc, #03, #51, #ae, #00, #ff, #1f, #e0, #ff, #00, #51, #ae, #00, #ff

#97e6

#3066

16

        db #1f, #e0, #ff, #00, #91, #6e, #40, #bf, #3f, #c0, #ff, #00, #e1, #1e, #50, #af

#97f6

#3076

16

        db #3f, #c0, #ff, #00, #fe, #01, #52, #ad, #7f, #80, #ff, #00, #ff, #00, #52, #ad

#9806

#3086

16

        db #ff, #00, #ff, #00, #ff, #00, #92, #6d, #ff, #00, #ff, #00, #ff, #00, #e2, #1d

#9816

#3096

10

        db #ff, #00, #ff, #00, #ff, #00, #fd, #02, #ff, #00

#9820

#30a0

    L9820_iso_additional_graphic_16:  ;

#9820

#30a0

16

        db #17, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9830

#30b0

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9840

#30c0

16

        db #ff, #00, #fc, #03, #ff, #00, #ff, #00, #f8, #07, #3f, #c0, #ff, #00, #f0, #0f

#9850

#30d0

16

        db #1f, #e0, #ff, #00, #f0, #0f, #2f, #d0, #ff, #00, #c0, #3f, #af, #50, #ff, #00

#9860

#30e0

16

        db #80, #7f, #9f, #60, #ff, #00, #00, #ff, #9f, #60, #ff, #00, #00, #ff, #bf, #40

#9870

#30f0

16

        db #fe, #01, #02, #fd, #7f, #80, #fc, #03, #02, #fd, #7f, #80, #fc, #03, #02, #fd

#9880

#3100

16

        db #7f, #80, #f8, #07, #02, #fd, #ff, #00, #f8, #07, #01, #fe, #ff, #00, #f0, #0f

#9890

#3110

16

        db #09, #f6, #ff, #00, #fc, #03, #0b, #f4, #ff, #00, #ff, #00, #0b, #f4, #ff, #00

#98a0

#3120

12

        db #ff, #00, #cb, #34, #ff, #00, #ff, #00, #f7, #08, #ff, #00

#98ac

#312c

    L98ac_iso_additional_graphic_17:  ;

#98ac

#312c

16

        db #11, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#98bc

#313c

16

        db #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #cf, #30, #ff, #00

#98cc

#314c

16

        db #ff, #00, #c1, #3e, #ff, #00, #ff, #00, #80, #7f, #ff, #00, #ff, #00, #80, #7f

#98dc

#315c

16

        db #3f, #c0, #ff, #00, #00, #ff, #07, #f8, #ff, #00, #80, #7f, #03, #fc, #fe, #01

#98ec

#316c

16

        db #a0, #5f, #03, #fc, #fe, #01, #a8, #57, #01, #fe, #fc, #03, #a9, #56, #0a, #f5

#98fc

#317c

16

        db #ff, #00, #29, #d6, #2a, #d5, #ff, #00, #c9, #36, #29, #d6, #ff, #00, #f1, #0e

#990c

#318c

8

        db #09, #f6, #ff, #00, #fe, #01, #73, #8c

#9914

#3194

    L9914_iso_additional_graphic_18:  ;

#9914

#3194

16

        db #20, #04, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #ff, #00, #0f, #b0, #ff, #00

#9924

#31a4

16

        db #ff, #00, #fe, #01, #03, #8c, #ff, #00, #ff, #00, #fe, #01, #00, #83, #ff, #00

#9934

#31b4

16

        db #ff, #00, #fc, #02, #00, #80, #3f, #c0, #ff, #00, #fc, #02, #00, #8c, #0f, #30

#9944

#31c4

16

        db #ff, #00, #f8, #06, #00, #8c, #03, #0c, #ff, #00, #f8, #06, #00, #c0, #00, #c3

#9954

#31d4

16

        db #ff, #00, #f0, #0b, #00, #30, #00, #c0, #7f, #80, #f0, #0b, #00, #0c, #00, #0c

#9964

#31e4

16

        db #7f, #80, #e0, #1a, #00, #03, #00, #0c, #7f, #80, #e0, #1a, #00, #00, #00, #c0

#9974

#31f4

16

        db #7f, #80, #c0, #2c, #00, #00, #00, #30, #7f, #80, #c0, #2c, #00, #00, #00, #0c

#9984

#3204

16

        db #7f, #80, #80, #68, #00, #00, #00, #03, #7f, #80, #80, #68, #00, #00, #00, #00

#9994

#3214

16

        db #7f, #80, #00, #b0, #00, #00, #00, #01, #ff, #00, #00, #b0, #00, #00, #00, #01

#99a4

#3224

16

        db #ff, #00, #00, #a0, #00, #00, #01, #02, #ff, #00, #00, #a0, #00, #00, #01, #02

#99b4

#3234

16

        db #ff, #00, #00, #c0, #00, #00, #03, #04, #ff, #00, #00, #c0, #00, #00, #03, #04

#99c4

#3244

16

        db #ff, #00, #00, #80, #00, #00, #07, #08, #ff, #00, #00, #c0, #00, #00, #07, #08

#99d4

#3254

16

        db #ff, #00, #c0, #30, #00, #00, #0f, #10, #ff, #00, #f0, #0c, #00, #00, #0f, #10

#99e4

#3264

16

        db #ff, #00, #fc, #03, #00, #00, #1f, #20, #ff, #00, #ff, #00, #00, #c0, #1f, #20

#99f4

#3274

16

        db #ff, #00, #ff, #00, #c0, #30, #3f, #40, #ff, #00, #ff, #00, #f0, #0c, #3f, #40

#9a04

#3284

16

        db #ff, #00, #ff, #00, #fc, #03, #7f, #80, #ff, #00, #ff, #00, #ff, #00, #7f, #80

#9a14

#3294

2

        db #ff, #00

#9a16

#3296

    L9a16_iso_additional_graphic_19:  ;

#9a16

#3296

16

        db #20, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0b, #ff, #00

#9a26

#32a6

16

        db #ff, #00, #ff, #00, #e0, #18, #3f, #c0, #ff, #00, #ff, #00, #e0, #18, #0f, #30

#9a36

#32b6

16

        db #ff, #00, #ff, #00, #c0, #28, #03, #0c, #ff, #00, #ff, #00, #c0, #28, #00, #c3

#9a46

#32c6

16

        db #ff, #00, #ff, #00, #80, #68, #00, #c0, #3f, #c0, #ff, #00, #80, #6c, #00, #0c

#9a56

#32d6

16

        db #0f, #30, #ff, #00, #00, #b3, #00, #0c, #07, #08, #ff, #00, #00, #b0, #00, #c0

#9a66

#32e6

16

        db #07, #c8, #fe, #01, #00, #a0, #00, #30, #07, #c8, #fe, #01, #00, #a0, #00, #0c

#9a76

#32f6

16

        db #07, #08, #fc, #02, #00, #c0, #00, #03, #07, #08, #fc, #02, #00, #c0, #00, #00

#9a86

#3306

16

        db #07, #c8, #f8, #06, #00, #80, #00, #00, #07, #38, #f8, #06, #00, #80, #00, #00

#9a96

#3316

16

        db #07, #08, #f0, #0b, #00, #00, #00, #00, #0f, #10, #f0, #0b, #00, #00, #00, #00

#9aa6

#3326

16

        db #0f, #10, #f0, #0a, #00, #00, #00, #00, #1f, #20, #f0, #0a, #00, #00, #00, #00

#9ab6

#3336

16

        db #1f, #20, #f0, #0c, #00, #00, #00, #00, #3f, #40, #f0, #0c, #00, #00, #00, #00

#9ac6

#3346

16

        db #3f, #40, #f0, #08, #00, #00, #00, #00, #7f, #80, #f0, #0c, #00, #00, #00, #00

#9ad6

#3356

16

        db #7f, #80, #fc, #03, #00, #00, #00, #01, #ff, #00, #ff, #00, #00, #c0, #00, #01

#9ae6

#3366

16

        db #ff, #00, #ff, #00, #c0, #30, #01, #02, #ff, #00, #ff, #00, #f0, #0c, #01, #02

#9af6

#3376

16

        db #ff, #00, #ff, #00, #fc, #03, #03, #04, #ff, #00, #ff, #00, #ff, #00, #03, #c4

#9b06

#3386

16

        db #ff, #00, #ff, #00, #ff, #00, #c7, #38, #ff, #00, #ff, #00, #ff, #00, #f7, #08

#9b16

#3396

2

        db #ff, #00

#9b18

#3398

    L9b18_iso_additional_graphic_20:  ;

#9b18

#3398

16

        db #28, #04, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #ff, #00, #0f, #b0, #ff, #00

#9b28

#33a8

16

        db #ff, #00, #fe, #01, #03, #8c, #ff, #00, #ff, #00, #fe, #01, #03, #84, #ff, #00

#9b38

#33b8

16

        db #ff, #00, #fc, #02, #03, #84, #ff, #00, #ff, #00, #fc, #02, #03, #84, #ef, #10

#9b48

#33c8

16

        db #ff, #00, #f8, #06, #03, #84, #e3, #1c, #ff, #00, #f8, #06, #01, #86, #c0, #33

#9b58

#33d8

16

        db #ff, #00, #f0, #0a, #00, #87, #40, #b0, #7f, #80, #f0, #0a, #00, #87, #00, #d0

#9b68

#33e8

16

        db #7f, #80, #e0, #1a, #00, #83, #00, #d0, #7f, #80, #e0, #1a, #00, #90, #00, #d0

#9b78

#33f8

16

        db #7f, #80, #c0, #2a, #00, #84, #00, #30, #7f, #80, #c0, #2a, #00, #91, #00, #00

#9b88

#3408

16

        db #7f, #80, #80, #6a, #00, #84, #00, #40, #7f, #80, #80, #6a, #00, #c1, #00, #10

#9b98

#3418

16

        db #7f, #80, #00, #ab, #00, #30, #00, #44, #7f, #80, #00, #ab, #00, #0c, #00, #10

#9ba8

#3428

16

        db #7f, #80, #00, #aa, #00, #03, #00, #04, #7f, #80, #00, #aa, #00, #00, #00, #c0

#9bb8

#3438

16

        db #7f, #80, #00, #ac, #00, #00, #00, #30, #7f, #80, #00, #ac, #00, #00, #00, #0c

#9bc8

#3448

16

        db #7f, #80, #00, #a8, #00, #00, #00, #03, #7f, #80, #00, #a8, #00, #00, #00, #00

#9bd8

#3458

16

        db #7f, #80, #00, #b0, #00, #00, #00, #01, #ff, #00, #00, #b0, #00, #00, #00, #01

#9be8

#3468

16

        db #ff, #00, #00, #a0, #00, #00, #01, #02, #ff, #00, #00, #a0, #00, #00, #01, #02

#9bf8

#3478

16

        db #ff, #00, #00, #c0, #00, #00, #03, #04, #ff, #00, #00, #c0, #00, #00, #03, #04

#9c08

#3488

16

        db #ff, #00, #00, #80, #00, #00, #07, #08, #ff, #00, #00, #c0, #00, #00, #07, #08

#9c18

#3498

16

        db #ff, #00, #c0, #30, #00, #00, #0f, #10, #ff, #00, #f0, #0c, #00, #00, #0f, #10

#9c28

#34a8

16

        db #ff, #00, #fc, #03, #00, #00, #1f, #20, #ff, #00, #ff, #00, #00, #c0, #1f, #20

#9c38

#34b8

16

        db #ff, #00, #ff, #00, #c0, #30, #3f, #40, #ff, #00, #ff, #00, #f0, #0c, #3f, #40

#9c48

#34c8

16

        db #ff, #00, #ff, #00, #fc, #03, #7f, #80, #ff, #00, #ff, #00, #ff, #00, #7f, #80

#9c58

#34d8

2

        db #ff, #00

#9c5a

#34da

    L9c5a_iso_additional_graphic_21:  ;

#9c5a

#34da

16

        db #28, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0b, #ff, #00

#9c6a

#34ea

16

        db #ff, #00, #ff, #00, #e0, #18, #3f, #c0, #ff, #00, #ff, #00, #e0, #18, #3f, #40

#9c7a

#34fa

16

        db #ff, #00, #ff, #00, #c0, #28, #3f, #40, #ff, #00, #ff, #00, #c0, #28, #3e, #41

#9c8a

#350a

16

        db #ff, #00, #ff, #00, #80, #68, #3e, #41, #3f, #c0, #ff, #00, #80, #68, #1c, #63

#9c9a

#351a

16

        db #0f, #30, #ff, #00, #00, #a8, #04, #7b, #07, #08, #ff, #00, #00, #a8, #00, #7d

#9caa

#352a

16

        db #07, #08, #fe, #01, #00, #a8, #00, #3d, #07, #08, #fe, #01, #00, #a9, #00, #0d

#9cba

#353a

16

        db #07, #08, #fc, #02, #00, #a8, #00, #43, #07, #08, #fc, #02, #00, #a9, #00, #10

#9cca

#354a

16

        db #07, #08, #f8, #06, #00, #a8, #00, #44, #07, #08, #f8, #06, #00, #ac, #00, #11

#9cda

#355a

16

        db #07, #08, #f0, #0a, #00, #b3, #00, #04, #07, #48, #f0, #0a, #00, #b0, #00, #c1

#9cea

#356a

16

        db #07, #08, #f0, #0a, #00, #a0, #00, #30, #07, #48, #f0, #0a, #00, #a0, #00, #0c

#9cfa

#357a

16

        db #07, #08, #f0, #0a, #00, #c0, #00, #03, #07, #08, #f0, #0a, #00, #c0, #00, #00

#9d0a

#358a

16

        db #07, #c8, #f0, #0a, #00, #80, #00, #00, #07, #38, #f0, #0a, #00, #80, #00, #00

#9d1a

#359a

16

        db #07, #08, #f0, #0b, #00, #00, #00, #00, #0f, #10, #f0, #0b, #00, #00, #00, #00

#9d2a

#35aa

16

        db #0f, #10, #f0, #0a, #00, #00, #00, #00, #1f, #20, #f0, #0a, #00, #00, #00, #00

#9d3a

#35ba

16

        db #1f, #20, #f0, #0c, #00, #00, #00, #00, #3f, #40, #f0, #0c, #00, #00, #00, #00

#9d4a

#35ca

16

        db #3f, #40, #f0, #08, #00, #00, #00, #00, #7f, #80, #f0, #0c, #00, #00, #00, #00

#9d5a

#35da

16

        db #7f, #80, #fc, #03, #00, #00, #00, #01, #ff, #00, #ff, #00, #00, #c0, #00, #01

#9d6a

#35ea

16

        db #ff, #00, #ff, #00, #c0, #30, #01, #02, #ff, #00, #ff, #00, #f0, #0c, #01, #02

#9d7a

#35fa

16

        db #ff, #00, #ff, #00, #fc, #03, #03, #04, #ff, #00, #ff, #00, #ff, #00, #03, #c4

#9d8a

#360a

16

        db #ff, #00, #ff, #00, #ff, #00, #c7, #38, #ff, #00, #ff, #00, #ff, #00, #f7, #08

#9d9a

#361a

2

        db #ff, #00

#9d9c

#361c

    L9d9c_iso_additional_graphic_22:  ;

#9d9c

#361c

16

        db #19, #03, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #0f, #b0, #ff, #00, #fe, #01

#9dac

#362c

16

        db #0b, #d4, #ff, #00, #fe, #01, #08, #77, #ff, #00, #ff, #00, #18, #a4, #7f, #80

#9dbc

#363c

16

        db #ff, #00, #bc, #43, #cf, #30, #f8, #07, #cf, #30, #c3, #2c, #f8, #05, #82, #4d

#9dcc

#364c

16

        db #81, #56, #f1, #0a, #83, #74, #81, #7a, #f1, #0a, #03, #9c, #c9, #36, #e1, #16

#9ddc

#365c

16

        db #0e, #d1, #7f, #80, #e3, #1c, #df, #20, #23, #dc, #ff, #00, #fb, #04, #e1, #16

#9dec

#366c

16

        db #c7, #38, #39, #c6, #c1, #2a, #87, #48, #90, #6f, #e1, #16, #8c, #73, #f0, #09

#9dfc

#367c

16

        db #e7, #18, #88, #56, #61, #96, #bf, #40, #c8, #35, #21, #5a, #ff, #00, #f8, #06

#9e0c

#368c

16

        db #73, #8c, #17, #e8, #fc, #03, #7e, #81, #0f, #30, #ff, #00, #ff, #00, #0f, #d0

#9e1c

#369c

16

        db #ff, #00, #c9, #36, #9f, #60, #ff, #00, #c0, #2d, #df, #20, #ff, #00, #e1, #12

#9e2c

#36ac

8

        db #ff, #00, #ff, #00, #f3, #0c, #ff, #00

#9e34

#36b4

    L9e34_iso_additional_graphic_23:  ;

#9e34

#36b4

16

        db #18, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#9e44

#36c4

16

        db #ff, #00, #ff, #00, #f8, #07, #ff, #00, #ff, #00, #ff, #00, #f0, #0a, #3f, #c0

#9e54

#36d4

16

        db #ff, #00, #ff, #00, #f8, #05, #33, #4c, #ff, #00, #ff, #00, #f8, #06, #61, #92

#9e64

#36e4

16

        db #ff, #00, #ff, #00, #dc, #23, #f1, #0a, #ff, #00, #ff, #00, #ff, #00, #db, #24

#9e74

#36f4

16

        db #9f, #60, #ff, #00, #f3, #0c, #ff, #00, #07, #d8, #ff, #00, #39, #c6, #8f, #70

#9e84

#3704

16

        db #07, #a8, #fe, #01, #1f, #20, #87, #58, #8f, #50, #ff, #00, #33, #cc, #84, #4b

#9e94

#3714

16

        db #df, #20, #ff, #00, #f0, #0b, #cc, #32, #7f, #80, #fc, #03, #60, #9d, #fe, #01

#9ea4

#3724

16

        db #7f, #80, #f8, #04, #60, #97, #ff, #00, #ff, #00, #f8, #07, #e1, #1a, #e3, #1c

#9eb4

#3734

16

        db #ff, #00, #f8, #05, #f9, #06, #c1, #2a, #ff, #00, #fd, #02, #ef, #10, #c3, #24

#9ec4

#3744

16

        db #ff, #00, #ff, #00, #3f, #c0, #87, #58, #ff, #00, #ff, #00, #d8, #27, #9f, #60

#9ed4

#3754

16

        db #ff, #00, #ff, #00, #fd, #02, #f9, #06, #ff, #00, #ff, #00, #ff, #00, #fd, #02

#9ee4

#3764

16

        db #ff, #00, #ff, #00, #ff, #00, #a7, #58, #ff, #00, #ff, #00, #ff, #00, #cf, #30

#9ef4

#3774

2

        db #ff, #00

#9ef6

#3776

    L9ef6_iso_additional_graphic_24:  ;

#9ef6

#3776

16

        db #19, #03, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #6f, #90, #ff, #00, #ff, #00

#9f06

#3786

16

        db #f7, #08, #ff, #00, #fe, #01, #5f, #a0, #ff, #00, #fc, #02, #47, #b8, #3f, #c0

#9f16

#3796

16

        db #fc, #03, #c2, #2d, #3f, #40, #ff, #00, #82, #55, #6f, #90, #fd, #02, #c7, #28

#9f26

#37a6

16

        db #fc, #03, #fc, #03, #66, #99, #3e, #c1, #f8, #04, #3f, #40, #73, #8c, #f8, #05

#9f36

#37b6

16

        db #3f, #40, #e0, #1b, #f9, #06, #31, #ce, #e0, #15, #cf, #30, #e0, #15, #f1, #0a

#9f46

#37c6

16

        db #ec, #13, #f0, #0b, #9b, #64, #fc, #02, #39, #c6, #8f, #50, #98, #67, #3f, #40

#9f56

#37d6

16

        db #0f, #90, #88, #54, #3f, #c0, #1f, #a0, #9c, #62, #71, #8e, #bf, #40, #fe, #01

#9f66

#37e6

16

        db #f0, #0b, #ff, #00, #ff, #00, #99, #66, #cf, #30, #ff, #00, #0f, #d0, #df, #20

#9f76

#37f6

16

        db #ff, #00, #8e, #51, #7f, #80, #ff, #00, #dc, #22, #3f, #40, #ff, #00, #fc, #03

#9f86

#3806

8

        db #3f, #40, #ff, #00, #ff, #00, #7f, #80

#9f8e

#380e

    L9f8e_iso_additional_graphic_25:  ;

#9f8e

#380e

16

        db #18, #04, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #fc, #03, #ff, #00

#9f9e

#381e

16

        db #ff, #00, #ff, #00, #fc, #02, #3f, #c0, #ff, #00, #ff, #00, #f8, #04, #7f, #80

#9fae

#382e

16

        db #ff, #00, #ff, #00, #f8, #07, #e3, #1c, #ff, #00, #ff, #00, #fb, #04, #c1, #2a

#9fbe

#383e

16

        db #ff, #00, #ff, #00, #8e, #71, #c1, #2a, #ff, #00, #ff, #00, #87, #58, #e3, #14

#9fce

#384e

16

        db #ff, #00, #ff, #00, #df, #20, #37, #c8, #8f, #70, #ff, #00, #ff, #00, #0e, #b1

#9fde

#385e

16

        db #0f, #90, #fe, #01, #79, #86, #87, #48, #9f, #60, #fe, #01, #30, #49, #cf, #30

#9fee

#386e

16

        db #ff, #00, #fc, #02, #11, #ae, #fc, #03, #7f, #80, #fe, #01, #3b, #44, #0c, #f2

#9ffe

#387e

16

        db #7f, #80, #fe, #01, #7f, #80, #0e, #91, #ff, #00, #fb, #04, #e3, #1c, #9f, #60

#a00e

#388e

16

        db #ff, #00, #ff, #00, #c1, #22, #b3, #4c, #ff, #00, #ff, #00, #61, #9a, #fd, #02

#a01e

#389e

16

        db #ff, #00, #ff, #00, #fb, #04, #ef, #10, #ff, #00, #ff, #00, #ff, #00, #c3, #2c

#a02e

#38ae

16

        db #ff, #00, #ff, #00, #fe, #01, #41, #b6, #ff, #00, #ff, #00, #ff, #00, #41, #aa

#a03e

#38be

16

        db #ff, #00, #ff, #00, #ff, #00, #c3, #34, #ff, #00, #ff, #00, #ff, #00, #e7, #18

#a04e

#38ce

2

        db #ff, #00

#a050

#38d0

    La050_iso_additional_graphic_26:  ;

#a050

#38d0

16

        db #24, #02, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00, #ff, #00

#a060

#38e0

16

        db #ff, #00, #ff, #00, #3f, #c0, #ff, #00, #0f, #f0, #fe, #01, #03, #ac, #fe, #01

#a070

#38f0

16

        db #00, #d7, #fc, #02, #00, #ab, #fc, #03, #00, #d5, #f8, #06, #00, #ab, #f8, #05

#a080

#3900

16

        db #00, #d5, #f8, #06, #00, #ab, #f8, #05, #00, #d5, #f8, #07, #00, #3b, #f8, #05

#a090

#3910

16

        db #00, #0d, #f8, #06, #00, #63, #f8, #06, #01, #5a, #f8, #04, #01, #ea, #f8, #06

#a0a0

#3920

16

        db #03, #dc, #fe, #01, #03, #ec, #ff, #00, #07, #d8, #ff, #00, #07, #e8, #ff, #00

#a0b0

#3930

16

        db #07, #d8, #ff, #00, #07, #e8, #ff, #00, #07, #f8, #ff, #00, #07, #b8, #ff, #00

#a0c0

#3940

16

        db #0f, #f0, #ff, #00, #cf, #30, #ff, #00, #df, #20, #ff, #00, #df, #20, #ff, #00

#a0d0

#3950

16

        db #df, #20, #ff, #00, #df, #20, #ff, #00, #df, #20, #ff, #00, #df, #20, #ff, #00

#a0e0

#3960

2

        db #df, #20

#a0e2

#3962

    La0e2_iso_additional_graphic_27:  ;

#a0e2

#3962

16

        db #20, #04, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #ff, #00, #0f, #b0, #ff, #00

#a0f2

#3972

16

        db #ff, #00, #fe, #01, #03, #8c, #ff, #00, #ff, #00, #fe, #01, #00, #a3, #ff, #00

#a102

#3982

16

        db #ff, #00, #fc, #03, #00, #a8, #3f, #c0, #ff, #00, #fc, #03, #00, #aa, #0f, #30

#a112

#3992

16

        db #ff, #00, #f8, #07, #00, #8a, #03, #8c, #ff, #00, #f8, #07, #00, #c2, #00, #a3

#a122

#39a2

16

        db #ff, #00, #f0, #0f, #00, #30, #00, #a8, #7f, #80, #f0, #0f, #00, #0c, #00, #2a

#a132

#39b2

16

        db #7f, #80, #e0, #1e, #00, #03, #00, #0a, #7f, #80, #e0, #1e, #00, #00, #00, #c2

#a142

#39c2

16

        db #7f, #80, #c0, #3c, #00, #00, #00, #30, #7f, #80, #c0, #3c, #00, #00, #00, #0c

#a152

#39d2

16

        db #7f, #80, #80, #78, #00, #00, #00, #03, #7f, #80, #80, #78, #00, #10, #00, #00

#a162

#39e2

16

        db #7f, #80, #00, #f0, #00, #10, #00, #01, #ff, #00, #00, #f0, #00, #21, #00, #01

#a172

#39f2

16

        db #ff, #00, #00, #e0, #00, #21, #01, #02, #ff, #00, #00, #e0, #00, #42, #01, #02

#a182

#3a02

16

        db #ff, #00, #00, #c0, #00, #42, #03, #04, #ff, #00, #00, #c0, #00, #04, #03, #04

#a192

#3a12

16

        db #ff, #00, #00, #80, #00, #04, #07, #08, #ff, #00, #00, #c0, #00, #00, #07, #08

#a1a2

#3a22

16

        db #ff, #00, #c0, #30, #00, #00, #0f, #10, #ff, #00, #f0, #0c, #00, #00, #0f, #10

#a1b2

#3a32

16

        db #ff, #00, #fc, #03, #00, #00, #1f, #20, #ff, #00, #ff, #00, #00, #c0, #1f, #20

#a1c2

#3a42

16

        db #ff, #00, #ff, #00, #c0, #30, #3f, #40, #ff, #00, #ff, #00, #f0, #0c, #3f, #40

#a1d2

#3a52

16

        db #ff, #00, #ff, #00, #fc, #03, #7f, #80, #ff, #00, #ff, #00, #ff, #00, #7f, #80

#a1e2

#3a62

2

        db #ff, #00

#a1e4

#3a64

    La1e4_iso_additional_graphic_28:  ;

#a1e4

#3a64

16

        db #20, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0b, #ff, #00

#a1f4

#3a74

16

        db #ff, #00, #ff, #00, #e0, #18, #3f, #c0, #ff, #00, #ff, #00, #e0, #1a, #0f, #30

#a204

#3a84

16

        db #ff, #00, #ff, #00, #c0, #28, #03, #8c, #ff, #00, #ff, #00, #c0, #2a, #00, #23

#a214

#3a94

16

        db #ff, #00, #ff, #00, #80, #68, #00, #88, #3f, #c0, #ff, #00, #80, #6c, #00, #22

#a224

#3aa4

16

        db #0f, #30, #ff, #00, #00, #b3, #00, #08, #07, #88, #ff, #00, #00, #b0, #00, #c2

#a234

#3ab4

16

        db #07, #28, #fe, #01, #00, #a0, #00, #30, #07, #88, #fe, #01, #00, #a0, #00, #0c

#a244

#3ac4

16

        db #07, #28, #fc, #02, #00, #c0, #00, #03, #07, #08, #fc, #02, #00, #c3, #00, #00

#a254

#3ad4

16

        db #07, #c8, #f8, #06, #03, #84, #00, #c0, #07, #38, #f8, #06, #03, #84, #c0, #30

#a264

#3ae4

16

        db #07, #08, #f0, #0b, #01, #0a, #e0, #1c, #0f, #10, #f0, #0b, #00, #0d, #60, #9e

#a274

#3af4

16

        db #0f, #10, #f0, #0a, #00, #1a, #00, #fc, #1f, #20, #f0, #0a, #00, #15, #00, #7c

#a284

#3b04

16

        db #1f, #20, #f0, #0c, #00, #2a, #00, #b8, #3f, #40, #f0, #0c, #00, #35, #00, #78

#a294

#3b14

16

        db #3f, #40, #f0, #08, #00, #0e, #00, #b0, #7f, #80, #f0, #0c, #00, #03, #00, #70

#a2a4

#3b24

16

        db #7f, #80, #fc, #03, #00, #00, #00, #e1, #ff, #00, #ff, #00, #00, #c0, #00, #21

#a2b4

#3b34

16

        db #ff, #00, #ff, #00, #c0, #30, #01, #02, #ff, #00, #ff, #00, #f0, #0c, #01, #02

#a2c4

#3b44

16

        db #ff, #00, #ff, #00, #fc, #03, #03, #04, #ff, #00, #ff, #00, #ff, #00, #03, #c4

#a2d4

#3b54

16

        db #ff, #00, #ff, #00, #ff, #00, #c7, #38, #ff, #00, #ff, #00, #ff, #00, #f7, #08

#a2e4

#3b64

2

        db #ff, #00

#a2e6

#3b66

    La2e6_iso_additional_graphic_29:  ;

#a2e6

#3b66

16

        db #28, #04, #ff, #00, #3f, #c0, #ff, #00, #ff, #00, #ff, #00, #0f, #b0, #ff, #00

#a2f6

#3b76

16

        db #ff, #00, #fe, #01, #03, #8c, #ff, #00, #ff, #00, #fe, #01, #00, #a3, #ff, #00

#a306

#3b86

16

        db #ff, #00, #fc, #02, #00, #a8, #3f, #c0, #ff, #00, #fc, #02, #00, #aa, #0f, #30

#a316

#3b96

16

        db #ff, #00, #f8, #04, #00, #aa, #03, #8c, #ff, #00, #f8, #04, #00, #ae, #00, #a3

#a326

#3ba6

16

        db #ff, #00, #f0, #08, #00, #a9, #00, #a8, #7f, #80, #f0, #0a, #00, #a8, #00, #6a

#a336

#3bb6

16

        db #7f, #80, #e0, #12, #00, #a8, #00, #1a, #7f, #80, #e0, #12, #00, #a8, #00, #0a

#a346

#3bc6

16

        db #7f, #80, #c0, #22, #00, #ac, #00, #1a, #7f, #80, #c0, #2a, #00, #ab, #00, #3a

#a356

#3bd6

16

        db #7f, #80, #80, #4a, #00, #8a, #00, #fa, #7f, #80, #80, #48, #00, #c2, #00, #ba

#a366

#3be6

16

        db #7f, #80, #00, #89, #00, #30, #00, #aa, #7f, #80, #00, #a9, #00, #0c, #00, #2a

#a376

#3bf6

16

        db #7f, #80, #00, #aa, #00, #43, #00, #0a, #7f, #80, #00, #a2, #00, #10, #00, #c2

#a386

#3c06

16

        db #7f, #80, #00, #a4, #00, #84, #00, #30, #7f, #80, #00, #a4, #00, #21, #00, #0c

#a396

#3c16

16

        db #7f, #80, #00, #a9, #00, #08, #00, #43, #7f, #80, #00, #88, #00, #42, #00, #10

#a3a6

#3c26

16

        db #7f, #80, #00, #92, #00, #10, #00, #85, #ff, #00, #00, #90, #00, #84, #00, #21

#a3b6

#3c36

16

        db #ff, #00, #00, #a4, #00, #21, #01, #0a, #ff, #00, #00, #a1, #00, #08, #01, #42

#a3c6

#3c46

16

        db #ff, #00, #00, #c8, #00, #42, #03, #14, #ff, #00, #00, #c2, #00, #10, #03, #84

#a3d6

#3c56

16

        db #ff, #00, #00, #90, #00, #84, #07, #28, #ff, #00, #00, #c4, #00, #21, #07, #08

#a3e6

#3c66

16

        db #ff, #00, #c0, #31, #00, #08, #0f, #50, #ff, #00, #f0, #0c, #00, #42, #0f, #10

#a3f6

#3c76

16

        db #ff, #00, #fc, #03, #00, #10, #1f, #a0, #ff, #00, #ff, #00, #00, #c4, #1f, #20

#a406

#3c86

16

        db #ff, #00, #ff, #00, #c0, #31, #3f, #40, #ff, #00, #ff, #00, #f0, #0c, #3f, #40

#a416

#3c96

16

        db #ff, #00, #ff, #00, #fc, #03, #7f, #80, #ff, #00, #ff, #00, #ff, #00, #7f, #80

#a426

#3ca6

2

        db #ff, #00

#a428

#3ca8

    La428_iso_additional_graphic_30:  ;

#a428

#3ca8

16

        db #28, #04, #ff, #00, #f3, #0c, #ff, #00, #ff, #00, #ff, #00, #f0, #0b, #ff, #00

#a438

#3cb8

16

        db #ff, #00, #ff, #00, #e0, #18, #3f, #c0, #ff, #00, #ff, #00, #e0, #18, #0f, #30

#a448

#3cc8

16

        db #ff, #00, #ff, #00, #c0, #2a, #03, #0c, #ff, #00, #ff, #00, #c0, #28, #00, #83

#a458

#3cd8

16

        db #ff, #00, #ff, #00, #80, #4a, #00, #08, #3f, #c0, #ff, #00, #80, #58, #00, #a8

#a468

#3ce8

16

        db #0f, #30, #ff, #00, #00, #d8, #00, #28, #07, #08, #ff, #00, #00, #c8, #00, #22

#a478

#3cf8

16

        db #07, #88, #fe, #01, #00, #ca, #00, #0a, #07, #28, #fe, #01, #00, #c8, #00, #aa

#a488

#3d08

16

        db #07, #88, #fc, #03, #00, #ca, #00, #28, #07, #28, #fc, #03, #00, #88, #00, #a2

#a498

#3d18

16

        db #07, #08, #f8, #05, #00, #a8, #00, #0a, #07, #08, #f8, #05, #00, #0c, #00, #0a

#a4a8

#3d28

16

        db #07, #88, #f0, #09, #00, #53, #00, #08, #07, #28, #f0, #08, #00, #10, #00, #c0

#a4b8

#3d38

16

        db #07, #88, #f0, #08, #00, #a4, #00, #30, #07, #28, #f0, #0c, #00, #20, #00, #0c

#a4c8

#3d48

16

        db #07, #08, #f0, #0d, #00, #40, #00, #43, #07, #08, #f0, #08, #00, #42, #00, #00

#a4d8

#3d58

16

        db #07, #c8, #f0, #0a, #00, #90, #00, #04, #07, #38, #f0, #08, #00, #80, #00, #00

#a4e8

#3d68

16

        db #07, #08, #f0, #09, #00, #01, #00, #00, #0f, #50, #f0, #09, #00, #00, #00, #02

#a4f8

#3d78

16

        db #0f, #10, #f0, #0a, #00, #42, #00, #10, #1f, #20, #f0, #0a, #00, #00, #00, #00

#a508

#3d88

16

        db #1f, #20, #f0, #0c, #00, #04, #00, #21, #3f, #40, #f0, #0c, #00, #20, #00, #00

#a518

#3d98

16

        db #3f, #40, #f0, #09, #00, #00, #00, #40, #7f, #80, #f0, #0c, #00, #00, #00, #00

#a528

#3da8

16

        db #7f, #80, #fc, #03, #00, #10, #00, #05, #ff, #00, #ff, #00, #00, #c0, #00, #21

#a538

#3db8

16

        db #ff, #00, #ff, #00, #c0, #31, #01, #02, #ff, #00, #ff, #00, #f0, #0c, #01, #02

#a548

#3dc8

16

        db #ff, #00, #ff, #00, #fc, #03, #03, #14, #ff, #00, #ff, #00, #ff, #00, #03, #c4

#a558

#3dd8

16

        db #ff, #00, #ff, #00, #ff, #00, #c7, #38, #ff, #00, #ff, #00, #ff, #00, #f7, #08

#a568

#3de8

2

        db #ff, #00