The game Memory Map

← Dunjunz

Addresses outside The game's own code that it uses at run time — zero-page workspace, RAM buffers, and memory-mapped I/O. For the code itself (&0400–&D8FE), see the disassembly listing.

Access: R read, W write, B indexing base — the address is named as base,X/,Y, so the byte actually touched is base + index and the literal byte at this address is never itself accessed.

Zero page

Address Name Access Description
&0000 tune_ptr
index region &0000–&0001

The music's place in the tune: the address of the three-byte step to play next. Set to the tune's start by start_music, advanced by music_event, and kept on the stack by start_level across a level load.

&0070 plot_x R/W

Sprite position: screen byte column, 0-79 (two MODE 2 pixels per byte). Also used as a scratch byte and pointer low byte by other routines.

&0071 plot_y R/W

Sprite position: pixel row from the top of the screen. Also used as a pointer high byte by other routines.

&0072 sprite_width R/W

Width of the sprite being plotted, in screen bytes.

&0073 sprite_height R/W

Height of the sprite being plotted, in pixel rows.

&0074 screen_ptr R/W

Screen address being written, low byte.

&0075 screen_ptr_hi R/W

Screen address being written, high byte.

&0076 row_start_ptr R/W

Screen address of the first byte of the sprite row being plotted, low byte.

&0077 row_start_ptr_hi R/W

Screen address of the first byte of the sprite row being plotted, high byte.

&0078 sprite_data_ptr R/W

Address of the next sprite data byte to plot, low byte.

&0079 sprite_data_ptr_hi R/W

Address of the next sprite data byte to plot, high byte.

&007A sprite_number R/W

Sprite to plot: an index into the sprite tables at sprite_addr_lo, sprite_addr_hi, sprite_widths and sprite_heights.

&007B map_ptr R/W

Pointer into room_walls or object_free_map at a cell's room, low byte; set by test_wall and test_object_free.

&007C map_ptr_hi R/W

Pointer into a map, high byte.

&007D plot_offset_x R/W

Horizontal offset added by plot_at_cell, in byte columns.

&007E plot_offset_y R/W

Vertical offset added by plot_at_cell, in pixel rows.

&0080 ring_x R/W

Map x of the cell being drawn in the victory ring.

&0081 ring_y R/W

Map y of the cell being drawn in the victory ring.

&0082 victory_sprite R/W

Sprite drawn in the victory ring: a sparkle, &16-&19, or the blank, &15, to erase it.

&0084 victory_delay R/W

Wait between passes of the victory sequence, in units of 255 loops: &E6 at the start, one less each pass, down to 1.

&008D victory_pitch_step R/W

Amount the victory tone's pitch rises each pass: 1 at the start, one more each time the pitch wraps past 255.

&008E victory_steps_left R/W

Pitch wraps left before the victory sequence ends: &32 (50) at the start.

&008F victory_pitch R/W

Pitch of the bell in the victory sequence, set with OSBYTE &D5.

OS workspace

Address Name Access Description
&00FA os_zp_fa

MOS zero-page workspace, read by dissolve_chalice to vary its random choice.

&00FC os_irq_a

MOS 1.20: A at the last interrupt, read by dissolve_chalice to vary its random choice.

&0240 os_vsync_counter R/W

MOS 1.20 counter decremented on every vertical sync interrupt. The game sets it and waits for it to run out to pace itself.

&0287 os_break_intercept
index region &0287–&0289
W

MOS BREAK intercept: a JMP here is called during a reset. *DUNJUNZ sets its address but leaves it disabled.

*DUNJUNZ and Coder2

Address Name Access Description
&08B0 unread_digit_table

In Dunj3: four bytes *DUNJUNZ sets to &69, which the game never reads.

&08B4 unread_hero_table

In Dunj3: four bytes *DUNJUNZ sets to 0, which the game never reads.

&08BC unread_level_count

In Dunj3: a byte *DUNJUNZ sets to 0, which the game never reads.

&08BD unread_level_digits
index region &08BD–&08BE

In Dunj3: two bytes *DUNJUNZ sets to "0 ", which the game never reads.

Game state

Address Name Access Description
&0D00 scratch B

General-purpose scratch byte.

&0D01 scratch2

Second scratch byte.

&0D02 cell_x

Map x of the cell being drawn, tested or moved to. plot_at_cell replaces it with the pixel offset within the room.

&0D03 cell_y

Map y of the cell being drawn, tested or moved to. plot_at_cell replaces it with the pixel offset within the room.

&0D04 cell_room

Room of the cell being drawn, as an offset into room_walls.

&0D06 previous_x

Map x of the creature being moved, before the move.

&0D07 previous_y

Map y of the creature being moved, before the move.

&0D08 previous_offset_x

Pixel offset of the hero being moved, before the move.

&0D09 previous_offset_y

Pixel offset of the hero being moved, before the move.

&0D10–&0D13 hero_x B

Map x of each hero.

&0D15–&0D18 hero_y B

Map y of each hero.

&0D1A–&0D1D hero_direction
index region &0D19–&0D1D
B

Direction each hero faces: 1 up, 3 right, 5 down, 7 left; 0 when the hero is not in play.

&0D20–&0D23 hero_frame
index region &0D1F–&0D23
B

Animation frame of each hero (0 or 1), added to its sprite.

&0D25–&0D28 hero_step B

Frames left in each hero's step between cells.

&0D2A–&0D2D hero_offset_x B

Each hero's horizontal pixel offset while between cells.

&0D30–&0D33 hero_offset_y B

Each hero's vertical pixel offset while between cells.

&0D40–&0D4B missile_x B

Map x of each missile (12 slots, three per hero).

&0D4C–&0D57 missile_y B

Map y of each missile.

&0D58–&0D63 missile_direction B

Direction of each missile: 1 up, 2 right, 3 down, 4 left; bit 7 set for a missile just fired; 0 for an empty slot.

&0D63 set_wrchv_low
&0D64–&0D6F missile_sprite_base B

Sprite base of each missile, to which its direction is added; also identifies the hero who fired it.

&0D70–&0D73 hero_key_up B

INKEY key number of each hero's up key.

&0D74–&0D77 hero_key_down B

INKEY key number of each hero's down key.

&0D78–&0D7B hero_key_right B

INKEY key number of each hero's right key.

&0D7C–&0D7F hero_key_left B

INKEY key number of each hero's left key.

&0D80–&0D83 hero_key_fire B

INKEY key number of each hero's fire key.

&0D90–&0D93 hero_health_tens
index region &0D8F–&0D93
B

Health tens digit, as a digit sprite (&1E-&27); &1D when the hero is dead.

&0D95–&0D98 hero_health_units B

Health units digit, as a digit sprite.

&0DA0–&0DA7 view_room
index region &0DA0–&0DA7
B

The room each hero's view shows: a pointer into room_walls, low byte then high byte, for each hero in turn (hero x at view_room + 2x).

&0DB0–&0DB3 hero_missile_sprites B

Sprite base of each hero's missiles: arrows, fireballs, axes, swords.

&0DB5–&0DB8 hero_sprites B

Sprite base of each hero, to which direction and frame are added.

&0DBC–&0DBF hero_has_boots B

Non-zero while the hero wears Boots of Speed.

&0DC0–&0DC7 bit_masks B

Bit masks for the cells of a room row, left to right: &80, &40 ... &01.

&0DD0–&0DD3 hero_panel_y B

Pixel row of each hero's section of the status panel.

&0DFD teleport_last

Index of the last object to search when looking backwards for a teleporter (&1E, from workspace_template).

&0DFF victory_sprite_copy

Written by draw_victory_ring; not read.

Level file (&6B00)

Address Name Access Description
&6B00–&6B1F level_object_x B

Level file: Objects' map x (entries 1-30, entry 30 the exit).

&6B20–&6B3F level_object_y B

Level file: Objects' map y.

&6B40–&6B5F level_object_type B

Level file: Objects' types.

&6B60–&6B74 level_door_x B

Level file: Doors' map x (entries 1-20).

&6B75–&6B89 level_door_y B

Level file: Doors' map y.

&6B8A–&6B9F level_door_sprite B

Level file: Doors' sprites.

&6BA0–&6BB4 level_key_x B

Level file: Keys' map x (entries 1-20).

&6BB5–&6BCF level_key_y B

Level file: Keys' map y.

&6BD0–&6BD7 level_trapdoor_x B

Level file: Trapdoors' map x (entries 0-7).

&6BD8–&6BDF level_trapdoor_y B

Level file: Trapdoors' map y.

&6BE0–&6CAF level_walls B

Level file: Wall map (&C9 bytes used).

&6CB0–&6D7F level_object_free_map B

Level file: Map of cells without objects (&C9 bytes used).

&6D80–&6DAF level_wall_sprite B

Level file: The level's wall block, copied to wall_sprite.

Private RAM (HAZEL)

Address Name Access Description
&C400–&C4FF saved_page_0d B

The MOS's page &0D (the filing system's NMI code and workspace), saved here by Coder and copied back by load_level before each level is loaded.

MOS internals

Address Name Access Description
&D9CD mos120_reset_entry

The MOS 1.20 reset entry, which decrypt_level calls on a failed checksum. On a Master, with private RAM paged in, it is HAZEL.

&E0A4 mos120_oswrch_default

MOS 1.20's default OSWRCH routine, where the unused handler would pass characters on; MOS 3.20's is elsewhere.

&E822 mos320_oswrch_default

MOS 3.20's default OSWRCH routine, WRCHV's initial value.

&EEB1 mos320_osbyte_default

MOS 3.20's default OSBYTE routine, BYTEV's initial value.

OS entry points

Address Name Access Description
&FFFC reset_vector
index region &FFFC–&FFFD

6502 RESET vector, in the MOS ROM.