The game
Dunjunz, unofficial sideways RAM hack
Updated 9 Nov 2026
This disassembly
Discussion
Feedback
Files
| File | Load | Exec | Length | SHA-256 |
|---|---|---|---|---|
| Dunjun4 | &0400 | &0400 | &0900 | 580fd7d2ad629d34c8786527e45a8b7327b42b005d4a4fdbd89b00793d1904b3 |
| Dunjun7 | &0D00 | &0D00 | &0400 | 44dc3f0b221d28f72d7f9acb9ee6b78153fff91e71a04b6499b644fbe8192682 |
| Dunjun5 | &1100 | &1100 | &1F00 | 3870c311ac4c48641a459b7be3eed1725b48d8af92556bb0901025b93b8e2843 |
| Dunjun6 | &6E80 | &6E80 | &1180 | b9ddb831abd82a11a3abd7bc874ca357655cdd360f5c992d366ef6f95e9c47c6 |
Add 1000 to a hero's scoreCarry a point into the thousands of hero X's score. add_ten_points calls it whenever the hundreds digit passes 9, and on return its draw_score redraws the four large digits (thousands to units) in the hero's panel section. The panel has room for only those four, so when the thousands digit passes 9 it goes back to 0 and the ten-thousands digit (hero_score_ten_thousands, a small digit sprite) goes up. That digit sticks at 9, so beyond 99,999 the large digits wrap while the small one stays at 9. Each change of the ten-thousands digit is drawn at draw_ten_thousands: the small digit &18 rows below the hero's panel row, under the score, followed by four of sprite &71. Sprite &71, the small 8, is a solid bar two pixels wide, the same shape a small 0 would have, so the line reads as a small N0000. remove_absent_heroes enters at draw_ten_thousands with the digit in A, to redraw the line on the fresh screen of each level. Uses plot_x, plot_y and sprite_number.
|
|||||||
| 0400 | .add_thousand_points←1← 72B9 JSR | ||||||
| INC hero_score_thousands,x ; One more thousand: the hundreds digit carried | |||||||
| 0403 | LDA hero_score_thousands,x ; ...and check the new digit | ||||||
| 0406 | CMP #spr_digit_9 + 1 ; Past 9: another ten thousand? | ||||||
| 0408 | BNE add_thousand_points_done ; No: return; draw_score shows the new digit | ||||||
| 040A | LDA #spr_digit_0 ; Yes: thousands 0... | ||||||
| 040C | STA hero_score_thousands,x ; ...stored for this hero | ||||||
| 040F | INC hero_score_ten_thousands,x ; ...and carry into the small ten-thousands digit | ||||||
| 0412 | LDA hero_score_ten_thousands,x ; ...and check the new digit | ||||||
| 0415 | CMP #spr_small_digit_9 + 1 ; Past small 9: a score of 100,000? | ||||||
| 0417 | BNE draw_ten_thousands ; No: draw it under the score | ||||||
| 0419 | LDA #spr_small_digit_9 ; Yes: it sticks at 9 | ||||||
| 041B | STA hero_score_ten_thousands,x ; ...stored for this hero | ||||||
| 041E | .draw_ten_thousands←2← 0417 BNE← 06C2 JSR | ||||||
| STA sprite_number ; Plot the ten-thousands digit under the score... | |||||||
| 0420 | LDA #panel_left ; ...at the panel's left column | ||||||
| 0422 | STA plot_x ; ...as the plot column | ||||||
| 0424 | LDA workspace_template + 208,x ; ...hero_panel_y, read from workspace_template | ||||||
| 0427 | CLC ; ...(carry clear for the add) | ||||||
| 0428 | ADC #&18 ; ...+ &18: below the score's rows, &0C-&15 | ||||||
| 042A | STA plot_y ; ...as the plot row | ||||||
| 042C | TXA ; Keep the hero number... | ||||||
| 042D | PHA ; ...on the stack while plotting | ||||||
| 042E | JSR plot_sprite ; Plot the ten-thousands digit | ||||||
| 0431 | LDA #spr_small_digit_8 ; ...then four small 0s after it: sprite &71... | ||||||
| 0433 | STA sprite_number ; ...(small 8, a solid bar, the shape of a small 0) | ||||||
| 0435 | LDY #4 ; ...four of them, for the 0000 | ||||||
| 0437 | .draw_ten_thousands_loop←1← 0443 BNE | ||||||
| TYA ; Keep the count... | |||||||
| 0438 | PHA ; ...on the stack while plotting | ||||||
| 0439 | INC plot_x ; Two byte columns right... | ||||||
| 043B | INC plot_x ; ...a small digit's width on | ||||||
| 043D | JSR plot_sprite ; Plot a 0 there | ||||||
| 0440 | PLA ; Recover the count... | ||||||
| 0441 | TAY ; ...of 0s still to plot, in Y | ||||||
| 0442 | DEY ; One fewer 0 to plot | ||||||
| 0443 | BNE draw_ten_thousands_loop ; More 0s: loop | ||||||
| 0445 | PLA ; Recover the hero number... | ||||||
| 0446 | TAX ; ...in X again, as on entry | ||||||
| 0447 | .add_thousand_points_done←1← 0408 BNE | ||||||
| RTS ; Return to draw_score (or remove_absent_heroes) | |||||||
UnusedZero bytes, which nothing reads. |
|
| 0448 | EQUB &00, &00, &00, &00, &00, &00, &00, &00 ; Zeros |
Decrypt and check the level just loadedDecrypt the level at &6B00-&6DAF in place, XORing each byte with the low byte of its own address, and sum the decrypted bytes. If the sum does not match the level's entry in level_checksums, call &D9CD, the reset entry of MOS 1.20, so a damaged or altered level file is never played. It runs once per level, as soon as the level file is in memory and before unpack_level copies it into the game's tables; it returns only if the level is intact, leaving it decrypted at &6B00. The pointer and the sum borrow the plotter's zero-page workspace (plot_x and plot_y, sprite_width), which nothing is using while a level loads.
|
||||
| 0450 | .decrypt_level←1← 149D JMP | |||
| LDY #0 ; Point at &6B00, the start of the level... | ||||
| 0452 | STY plot_x ; ...low byte 0, in plot_x (the pointer's low half) | |||
| 0454 | STY sprite_width ; Checksum 0, kept in sprite_width | |||
| 0456 | LDA #>(level_object_x) ; High byte &6B: the level buffer's page | |||
| 0458 | STA plot_y ; ...in plot_y (the pointer's high half) | |||
| 045A | .decrypt_level_loop←2← 046F BNE← 0475 BNE | |||
| LDA (plot_x),y ; Fetch a level byte... | ||||
| 045C | EOR plot_x ; ...XOR it with the low byte of its address... | |||
| 045E | STA (plot_x),y ; ...and store it back decrypted | |||
| 0460 | CLC ; Add the decrypted byte to the checksum... | |||
| 0461 | ADC sprite_width ; ...plus the sum so far | |||
| 0463 | STA sprite_width ; ...as the new sum, modulo 256 | |||
| 0465 | INC plot_x ; Advance the pointer to the next level byte... | |||
| 0467 | BNE decrypt_level_next ; No carry: same page | |||
| 0469 | INC plot_y ; ...with carry into the high byte | |||
| 046B | .decrypt_level_next←1← 0467 BNE | |||
| LDA plot_x ; Stop at &6DB0, the end of the level... | ||||
| 046D | CMP #<(level_file_end) ; ...low byte &B0? | |||
| 046F | BNE decrypt_level_loop ; No: decrypt the next byte | |||
| 0471 | LDA plot_y ; ...and high byte &6D? | |||
| 0473 | CMP #>(level_file_end) ; ...(the end page) | |||
| 0475 | BNE decrypt_level_loop ; No: decrypt the next byte | |||
| 0477 | LDX level_number ; X = the level just loaded (1-25) | |||
| 047A | LDA sprite_width ; Compare the checksum... | |||
| 047C | CMP level_checksums,x ; ...with this level's entry in the table | |||
| 047F | BEQ decrypt_level_done ; Match: the level is intact; return | |||
| 0481 | JSR mos_reset_entry ; No match: reset the machine (a MOS 1.20 address) | |||
| 0484 | .decrypt_level_done←1← 047F BEQ | |||
| RTS ; Return: the level at &6B00 is decrypted and intact | ||||
UnusedZero bytes, which nothing reads. |
|
| 0485 | EQUB &00, &00, &00, &00, &00, &00, ; Zeros &00, &00, &00, &00, &00 |
| ; The expected sum of each decrypted level, for levels 1-25 at ; level_checksums+1 to level_checksums+25. | |
| 0490 | .level_checksums←1Used as index base by← 047C CMP |
| EQUB &00 ; Entry 0: there is no level 0, so never read | |
Level checksumsOne byte per level, 1-25, indexed by level_number from level_checksums (whose entry 0 is unused): the sum, modulo 256, of the level's &2B0 decrypted bytes, which decrypt_level checks before the level is played. |
|
| 0491 | EQUB &62, &CD, &0C, &44, &1A, &22, &F6, &42, &21, &7D, &5D, &D8, &A0, &F1, &0F, &CC, &D3, &53, &3B, &83, &71, &B2, &6F, &F3, &F1 ; Levels 1-25, five to a row |
UnusedZero bytes, which nothing reads. |
|
| 04AA | EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 ; Zeros |
| 04BA | EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 ; Zeros |
| 04CA | EQUB &00, &00, &00, &00, &00 ; Zeros |
| ; Data of sprite &15, &1A, &77: 4 bytes x 12 rows. | |
| 04CF | .sprite_blank |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| 04FF | EQUB &00 ; Not referenced |
Choose the heroes and the soundThe screen before each game where the players choose who plays. It is called once per game, when a new game starts, after reset_hero has given every hero their starting attributes and before the first level. Set a text window the full width of the screen (MODE 2's 20 columns) and clear it, print the menu (print_menu) and read keys until SPACE. Keys 1-4 toggle a hero between YES and NO by flipping their hero_absent flag and rewriting the menu entry; 5 and 6 switch the sound on and off with OSBYTE &D2. After each change the whole menu is reprinted. SPACE returns, so the game starts, only if at least one hero is playing. Before each key is read, the keyboard buffer is flushed and CAPS LOCK is forced on with SHIFT LOCK off. Neither hero_absent nor the menu text is set up here: the menu opens with whatever they held, which after a game over in the same load is the last game's choices. The ON/OFF entry shows only what was last chosen on the menu, not the sound suppression actually in force. hero_absent is read by remove_absent_heroes at each level.
|
||||||||
| 0500 | .hero_menu←1← 0E11 JSR | |||||||
| LDA #&1c ; VDU 28: the menu's window, the screen's full width... | ||||||||
| 0502 | JSR oswrch ; Send VDU 28 | |||||||
| 0505 | LDA #0 ; Left column 0 | |||||||
| 0507 | JSR oswrch ; Send the left column | |||||||
| 050A | LDA #&18 ; Bottom row of the window | |||||||
| 050C | JSR oswrch ; Send the bottom row | |||||||
| 050F | LDA #&13 ; Right column 19, MODE 2's last | |||||||
| 0511 | JSR oswrch ; Send the right column | |||||||
| 0514 | LDA #0 ; Top row 0 | |||||||
| 0516 | JSR oswrch ; Send the top row | |||||||
| 0519 | LDA #&0c ; ...VDU 12 to clear it | |||||||
| 051B | JSR oswrch ; Send VDU 12: clear the window | |||||||
| 051E | JSR print_menu ; Print the menu | |||||||
| 0521 | JMP menu_key_loop ; Read keys until the players start the game | |||||||
Print the menu textPrint the sixteen positioned strings of menu_text, in their current state, through print_menu_string: fifteen in a loop and the sixteenth by falling into print_menu_string, whose return is this routine's. Called by hero_menu to show the menu and after every change.
|
||||||||
| 0524 | .print_menu←3← 051E JSR← 05C3 JSR← 05F0 JSR | |||||||
| LDX #&0f ; Fifteen strings, then one more by falling through | ||||||||
| 0526 | LDY #0 ; Y walks through menu_text from its start | |||||||
| 0528 | .print_menu_loop←1← 052C BNE | |||||||
| JSR print_menu_string ; Print one menu string | ||||||||
| 052B | DEX ; One fewer to print | |||||||
| 052C | BNE print_menu_loop ; More to print: loop | |||||||
| fall through ↓ | ||||||||
Print one menu stringMove the text cursor to the column and row in the two bytes at menu_text+Y, then print the following characters up to and including a carriage return.
|
|||||||
| 052E | .print_menu_string←1← 0528 JSR | ||||||
| LDA #&1f ; VDU 31: move the text cursor... | |||||||
| 0530 | JSR oswrch ; Send VDU 31 | ||||||
| 0533 | LDA menu_text,y ; ...to the string's column... | ||||||
| 0536 | JSR oswrch ; Send the column | ||||||
| 0539 | INY ; Step to the row byte | ||||||
| 053A | LDA menu_text,y ; ...and the string's row... | ||||||
| 053D | JSR oswrch ; Send the row | ||||||
| 0540 | .print_menu_string_loop←1← 0549 BNE | ||||||
| INY ; Print the characters... | |||||||
| 0541 | LDA menu_text,y ; ...the next character... | ||||||
| 0544 | JSR oswrch ; ...sent to the screen... | ||||||
| 0547 | CMP #&0d ; ...up to and including the carriage return | ||||||
| 0549 | BNE print_menu_string_loop ; Not the CR yet: next character | ||||||
| 054B | INY ; Point at the next string | ||||||
| 054C | RTS ; Return with Y at the next string's column byte | ||||||
Change a menu entry to NOWrite "NO " over a hero's YES/NO entry at menu_text+Y, when hero_menu switches the hero off. print_menu then shows it.
|
||||
| 054D | .set_menu_no←1← 05C0 JSR | |||
| LDA #'N' ; "NO ": N first... | ||||
| 054F | STA menu_text,y ; ...into the entry's first letter | |||
| 0552 | LDA #'O' ; ...then O... | |||
| 0554 | STA menu_text + 1,y ; ...into the second letter | |||
| 0557 | LDA #' ' ; A space third, over YES's S... | |||
| 0559 | STA menu_text + 2,y ; ...into the third letter | |||
| 055C | RTS ; Return: the entry reads NO | |||
Change a menu entry to YESWrite "YES" over a hero's YES/NO entry at menu_text+Y, when hero_menu switches the hero on. print_menu then shows it.
|
||||
| 055D | .set_menu_yes←1← 05BA JSR | |||
| LDA #'Y' ; "YES": Y first... | ||||
| 055F | STA menu_text,y ; ...into the entry's first letter | |||
| 0562 | LDA #'E' ; ...then E... | |||
| 0564 | STA menu_text + 1,y ; ...into the second letter | |||
| 0567 | LDA #'S' ; ...then S... | |||
| 0569 | STA menu_text + 2,y ; ...into the third letter | |||
| 056C | RTS ; Return: the entry reads YES | |||
Change the sound entry to OFFWrite "FF" at menu_text+Y, after the sound entry's "O", when key 6 turns the sound off.
|
||||
| 056D | .set_menu_off←1← 05E4 JSR | |||
| LDA #'F' ; "FF" after the O | ||||
| 056F | STA menu_text,y ; ...over the N of ON... | |||
| 0572 | STA menu_text + 1,y ; ...and the space after it | |||
| 0575 | RTS ; Return: the entry reads OFF | |||
Change the sound entry to ONWrite "N " at menu_text+Y, after the sound entry's "O", when key 5 turns the sound on.
|
||||
| 0576 | .set_menu_on←1← 05DD JSR | |||
| LDA #'N' ; "N " after the O | ||||
| 0578 | STA menu_text,y ; ...over OFF's first F | |||
| 057B | LDA #' ' ; ...then a space... | |||
| 057D | STA menu_text + 1,y ; ...over OFF's second F | |||
| 0580 | RTS ; Return: the entry reads ON | |||
| ; Read one key and act on it, then come back for the next, until ; SPACE starts the game. | ||||
| 0581 | .menu_key_loop←6← 0521 JMP← 0598 BCC← 059C BCS← 05C6 JMP← 05D3 JMP← 05F3 JMP | |||
| LDA #osbyte_flush_buffer_class ; Flush the input buffers | ||||
| 0583 | JSR osbyte ; Discard any keys already waiting Flush selected class of buffer | |||
| 0586 | LDA #osbyte_kbd_status ; OSBYTE &CA: set the keyboard lock states... | |||
| 0588 | LDX #&20 ; X = &20: CAPS LOCK on, SHIFT LOCK off | |||
| 058A | LDY #0 ; Y = 0: replace the status with X | |||
| 058C | JSR osbyte ; Set it, whatever the Ranger's lock keys left osbyte: kbd status | |||
| 058F | JSR osrdch ; Wait for a key | |||
| 0592 | CMP #' ' ; SPACE, to start the game? | |||
| 0594 | BEQ menu_space ; Yes: start, if anyone is playing | |||
| 0596 | CMP #'1' ; Ignore anything but 1-6 | |||
| 0598 | BCC menu_key_loop ; Below '1': ignore it | |||
| 059A | CMP #'7' ; ...or above '6' (at or past '7')? | |||
| 059C | BCS menu_key_loop ; Yes: ignore it | |||
| 059E | SEC ; Key number 0-5 = key - '1'... | |||
| 059F | SBC #'1' ; ...so keys '1'-'6' become 0-5... | |||
| 05A1 | TAX ; ...in X: a hero 0-3, or 4-5 for the sound | |||
| 05A2 | CMP #4 ; Key 5 or 6? | |||
| 05A4 | BCS menu_sound_key ; Yes: the sound switch | |||
| ; Keys 1-4: switch hero X between playing and absent, and show ; it as YES or NO. | ||||
| 05A6 | ASL ; 1-4: Y = offset of the hero's YES/NO, 6 x X + &51... | |||
| 05A7 | STA plot_x ; Keep 2 x the hero number | |||
| 05A9 | ASL ; 4 x the hero number... | |||
| 05AA | CLC ; ...(carry clear for the add) | |||
| 05AB | ADC plot_x ; ...+ 2 x: 6 x the hero number | |||
| 05AD | ADC #&51 ; ...+ &51: this hero's YES/NO text | |||
| 05AF | TAY ; Y = its offset in menu_text | |||
| 05B0 | LDA hero_absent,x ; Toggle the hero between playing and absent... | |||
| 05B3 | EOR #1 ; ...by flipping the absent flag | |||
| 05B5 | STA hero_absent,x ; ...the hero's new absent flag | |||
| 05B8 | BNE menu_hero_off ; Now absent (flag 1)? | |||
| 05BA | JSR set_menu_yes ; No: playing, so the entry reads YES | |||
| 05BD | JMP menu_reprint ; ...and reprint the menu | |||
| 05C0 | .menu_hero_off←1← 05B8 BNE | |||
| JSR set_menu_no ; Absent: the entry reads NO | ||||
| 05C3 | .menu_reprint←1← 05BD JMP | |||
| JSR print_menu ; Reprint the menu with the change | ||||
| 05C6 | JMP menu_key_loop ; Wait for the next key | |||
| ; SPACE: return, so the game starts, if at least one hero is ; playing; otherwise ignore it. | ||||
| 05C9 | .menu_space←1← 0594 BEQ | |||
| LDX #3 ; SPACE: is any hero playing? | ||||
| 05CB | .menu_space_check_hero←1← 05D1 BPL | |||
| LDA hero_absent,x ; Is this hero playing (absent flag 0)? | ||||
| 05CE | BEQ menu_done ; Yes: return, and the game starts | |||
| 05D0 | DEX ; Absent: try the previous hero | |||
| 05D1 | BPL menu_space_check_hero ; Heroes left to check: loop | |||
| 05D3 | JMP menu_key_loop ; Nobody playing: ignore SPACE | |||
| 05D6 | .menu_done←1← 05CE BEQ | |||
| RTS ; Return: the game goes on to its first level | ||||
| ; Keys 5 and 6: sound on or off, through OSBYTE &D2, and the ; menu's entry to match. | ||||
| 05D7 | .menu_sound_key←1← 05A4 BCS | |||
| LDY #&99 ; Sound: Y = offset of the second letter of ON/OFF | ||||
| 05D9 | CMP #5 ; Key 6 (A = key - "1")? | |||
| 05DB | BEQ menu_sound_off ; Yes: sound off | |||
| 05DD | JSR set_menu_on ; Key 5: ON... | |||
| 05E0 | LDX #0 ; ...with X = 0 to enable the sound | |||
| 05E2 | BEQ menu_set_sound ; Always: set the sound | |||
| 05E4 | .menu_sound_off←1← 05DB BEQ | |||
| JSR set_menu_off ; Key 6: OFF... | ||||
| 05E7 | LDX #1 ; ...with X = 1 to suppress it | |||
| 05E9 | .menu_set_sound←1← 05E2 BEQ | |||
| LDA #osbyte_sound_suppression ; OSBYTE &D2: sound suppression | ||||
| 05EB | LDY #0 ; Y = 0: replace the setting with X | |||
| 05ED | JSR osbyte ; Turn the sound on or off as chosen osbyte: sound suppression | |||
| 05F0 | JSR print_menu ; Reprint the menu with the change | |||
| 05F3 | JMP menu_key_loop ; Wait for the next key | |||
| 05F6 | EQUB &00, &00, &00, &00, &00, &00, &00, &00, ; Not &00, &4F ; referenced | |||
Hero menu textSixteen entries of: column, row, text, carriage return; printed in order by print_menu, each at its own text position. The four heroes' YES/NO entries (text at menu_text + &51 + 6 x hero) are rewritten by set_menu_yes and set_menu_no, and the sound entry's ON/OFF (second letter at menu_text + &99) by set_menu_on and set_menu_off, so the table holds the players' choices as well as showing them. |
|
| ; The hero menu: sixteen strings, each a text column and row ; followed by the characters and a carriage return. The YES/NO ; and ON/OFF entries are rewritten as the players toggle them. | |
| 0600 | .menu_text←7Used as index base by← 0533 LDA← 053A LDA← 0541 LDA← 054F STA← 055F STA← 056F STA← 0578 STA |
| EQUB &06, &00 ; Column 6, row 0 | |
| 0602 | EQUS "DUNJUNZ", &0D |
| 060A | EQUB &00, &02 ; Column 0, row 2 |
| 060C | EQUS "HERO", &0D |
| 0611 | EQUB &0C, &02 ; Column 12, row 2 |
| 0613 | EQUS "PLAYING", &0D |
| 061B | EQUB &00, &04 ; Column 0, row 4 |
| 061D | EQUS "1 RANGER", &0D |
| 0626 | EQUB &00, &05 ; Column 0, row 5 |
| 0628 | EQUS "2 MAGIC-USER", &0D |
| 0635 | EQUB &00, &06 ; Column 0, row 6 |
| 0637 | EQUS "3 BARBARIAN", &0D |
| 0643 | EQUB &00, &07 ; Column 0, row 7 |
| 0645 | EQUS "4 FIGHTER", &0D |
| 064F | EQUB &0E, &04 ; Column 14, row 4 |
| 0651 | EQUS "YES", &0D |
| 0655 | EQUB &0E, &05 ; Column 14, row 5 |
| 0657 | EQUS "YES", &0D |
| 065B | EQUB &0E, &06 ; Column 14, row 6 |
| 065D | EQUS "YES", &0D |
| 0661 | EQUB &0E, &07 ; Column 14, row 7 |
| 0663 | EQUS "YES", &0D |
| 0667 | EQUB &00, &09 ; Column 0, row 9 |
| 0669 | EQUS "TYPE NUMBER", &0D |
| 0675 | EQUB &00, &0A ; Column 0, row 10 |
| 0677 | EQUS "TO TOGGLE", &0D |
| 0681 | EQUB &00, &0D ; Column 0, row 13 |
| 0683 | EQUS "SOUND ON(5) OFF(6)", &0D |
| 0696 | EQUB &07, &0F ; Column 7, row 15 |
| 0698 | EQUS "ON ", &0D |
| 069C | EQUB &03, &14 ; Column 3, row 20 |
| 069E | EQUS "SPACE TO PLAY", &0D |
| 06AC | EQUB &00, &0D, &A9, &63 ; Not referenced |
Take the heroes nobody plays out of the levelThe last step of setting up each level, called by level_loop after draw_status_panel and just before play_level. For each hero in turn: First redraw the small ten-thousands line under the score, if it has one (through draw_ten_thousands), since start_level cleared the screen and draw_status_panel draws only the four large digits. Then, if the hero was switched off on the menu (hero_absent), take them out of play, since reset_workspace has just given every hero their starting state: direction 0; step_out_of_play, so move_heroes passes over them; frame 8 and dead health, so that play_level treats them as dead with their death animation over, and level_loop counts them among the dead (and resets them) when the level ends; map x &1F; and a nobody_returns entry in returning_hero_queue, which reset_monsters has just emptied. The absent heroes' entries go at the front of the queue, in hero order; a Cross of Resurrection sends such an entry to the back and takes the next. Their panel section keeps the health and score just drawn.
|
||||||||
| 06B0 | .remove_absent_heroes←1← 0E5D JSR | |||||||
| LDX #0 ; Hero 0 first... | ||||||||
| 06B2 | LDY #0 ; ...Y = the queue entry for the next absent hero | |||||||
| 06B4 | .remove_absent_heroes_loop←1← 06F3 BNE | |||||||
| LDA hero_score_ten_thousands,x ; Score of 10000 or more? | ||||||||
| 06B7 | CMP #spr_small_digit_1 ; ...ten-thousands sprite small 1 or above? | |||||||
| 06B9 | BCC remove_absent_heroes_check ; No: nothing under the score; check absence | |||||||
| 06BB | TXA ; Yes: redraw it, lost when the screen was cleared | |||||||
| 06BC | PHA ; Keep the hero number... | |||||||
| 06BD | TYA ; ...and the queue entry... | |||||||
| 06BE | PHA ; ...on the stack | |||||||
| 06BF | LDA hero_score_ten_thousands,x ; The digit's sprite... | |||||||
| 06C2 | JSR draw_ten_thousands ; ...drawn under the score with its 0000 | |||||||
| 06C5 | PLA ; Recover the queue entry... | |||||||
| 06C6 | TAY ; ...for the next absent hero, in Y | |||||||
| 06C7 | PLA ; Recover the hero number... | |||||||
| 06C8 | TAX ; ...in X again | |||||||
| ; Take the hero out of play if nobody is playing them, so that ; they count as dead, and a Cross of Resurrection passes over ; their queue entry. | ||||||||
| 06C9 | .remove_absent_heroes_check←1← 06B9 BCC | |||||||
| LDA hero_absent,x ; Switched off on the menu? | ||||||||
| 06CC | BEQ remove_absent_heroes_next ; No: playing; next hero | |||||||
| 06CE | LDA #0 ; Yes: take them out of play... | |||||||
| 06D0 | STA hero_direction,x ; ...direction 0: not in play | |||||||
| 06D3 | LDA #step_out_of_play ; ...step &63, so move_heroes passes them over... | |||||||
| 06D5 | STA hero_step,x ; ...as the hero's step count | |||||||
| 06D8 | LDA #8 ; ...frame 8: their death animation is over... | |||||||
| 06DA | STA hero_frame,x ; ...as the hero's frame | |||||||
| 06DD | LDA #spr_digit_0 - 1 ; ...health tens below 0: dead... | |||||||
| 06DF | STA hero_health_tens,x ; ...as the health tens digit | |||||||
| 06E2 | DEC hero_score_units,x ; ...units back below 0, undoing the panel's point | |||||||
| 06E5 | LDA #&1f ; ...map x &1F, the dungeon's last column... | |||||||
| 06E7 | STA hero_x,x ; ...as the hero's map x | |||||||
| 06EA | LDA #nobody_returns ; ...and a nobody_returns entry in the queue... | |||||||
| 06EC | STA returning_hero_queue,y ; ...which a Cross of Resurrection skips | |||||||
| 06EF | INY ; The next absent hero takes the next entry | |||||||
| 06F0 | .remove_absent_heroes_next←1← 06CC BEQ | |||||||
| INX ; Next hero, 0-3 | ||||||||
| 06F1 | CPX #4 ; All four heroes done? | |||||||
| 06F3 | BNE remove_absent_heroes_loop ; No: next hero | |||||||
| 06F5 | RTS ; Return to level_loop: the level is ready to play | |||||||
UnusedZero bytes, which nothing reads. |
|
| 06F6 | EQUB &00, &00 ; Zeros |
| ; Each hero's score ten-thousands digit as a small digit sprite ; (&69 for none, &6A-&72 for 1-9). reset_hero sets it to &69, ; and remove_absent_heroes redraws the digit from here under the ; score at each level. | |
| 06F8 | .hero_score_ten_thousands←6Used as index base by← 040F INC← 0412 LDA← 041B STA← 06B4 LDA← 06BF LDA← 0EF3 STA |
| EQUS "iiii" | |
| ; One flag per hero: 1 if switched off on the menu, 0 if ; playing. hero_menu toggles it with keys 1-4; ; remove_absent_heroes takes the absent heroes out of play at ; each level. | |
| 06FC | .hero_absent←4Used as index base by← 05B0 LDA← 05B5 STA← 05CB LDA← 06C9 LDA |
| EQUB &00, &00, &00, &00 | |
Leftovers in the line-input bufferNot used by the game. &0700 is the MOS 1.20 line-input buffer, and these bytes are what it held when this image was saved: the command *SAVE Dunjunz.K 400 7FF 740, then a fragment of BBC BASIC assembler (label+2:LDA#255:.label JSR&30). |
|
| ; Leftover contents of the MOS 1.20 line-input buffer (&0700) ; from the machine the image was saved on. | |
| 0700 | .line_buffer_leftovers |
| EQUS "*SAVE Dunjunz.K 400 7FF 740" | |
| 071B | EQUB &0D, &54, &50, &0D, &0D, &50, &0D ; Not referenced |
| 0722 | EQUS "Alabel+2:LDA#255:.label JSR&30" |
Load the game file and run it (not used)Build an OSFILE control block at &6B00 naming boot_filename with load address &2000, call the filing system's FILEV handler to load the file, and jump to &2000. &0740 is the execution address in the *SAVE command left at &0700, so this is the image's own entry point when it is *RUN, but nothing in this release reaches it. The JSR's stored operand is &F27D, the MOS 1.20 FILEV handler for the cassette and ROM filing systems, so the image was saved after this loader had run with one of them selected. |
|
| 0740 | .boot_loader |
| LDX #<(boot_osfile_block) ; X/Y = &6B00, the control block... | |
| 0742 | LDY #>(boot_osfile_block) ; ...Y = &6B, its page |
| 0744 | LDA #<(boot_filename) ; Filename address: boot_filename... |
| 0746 | STA boot_osfile_block ; ...into the block's filename pointer, low byte |
| 0749 | LDA #>(boot_filename) ; ...boot_filename's high byte |
| 074B | STA boot_osfile_block + 1 ; ...into the filename pointer's high byte |
| 074E | LDA #0 ; Load address &00002000... |
| 0750 | STA boot_osfile_block + 2 ; ...load address byte 0 = 0 |
| 0753 | STA boot_osfile_block + 4 ; ...byte 2 = 0 |
| 0756 | STA boot_osfile_block + 5 ; ...byte 3 = 0 |
| 0759 | LDA #&20 ; ...byte 1 = &20 |
| 075B | STA boot_osfile_block + 3 ; ...so the file loads at &00002000 |
| 075E | LDA filev ; Copy FILEV into the JSR below... |
| 0761 | STA boot_load_call + 1 ; ...FILEV low byte into the JSR's operand |
| 0764 | LDA filev + 1 ; ...FILEV high byte |
| 0767 | STA boot_load_call + 2 ; ...so the JSR calls the filing system directly |
| 076A | LDA #&ff ; OSFILE &FF: load the file at the block's address |
| 076C | .boot_load_call |
| JSR &f27d ; Call FILEV (operand patched above) | |
| 076F | JMP &2000 ; Enter the loaded game at &2000 |
| 0772 | EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 ; Not referenced |
Name of the file boot_loader loads |
|
| 07F0 | .boot_filename |
| EQUS "Dunjunz1" | |
| 07F8 | EQUB &0D, &00, &00, &00, &00, &00, &00, &00, &FF, &00, ; No &00, &00, &00, &00, &00, &00, &C0, &C0, &C0, &C0, ; t &04, &04, &04, &04, &00, &00, &00, &64, &00, &00, ; re &00, &FF, &00, &00, &00, &00, &00, &00, &00, &00, ; fe &00, &00, &00, &05, &00, &00, &00, &FF, &00, &00, ; re &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; nc &00, &00, &00, &00, &FF, &00, &00, &00, &00, &F0, ; ed &00, &0E, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &64, &02, &90, &64, &02, &07, &90, &64, &07, &90, &64, &02, &90, &64, &07, &90, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &0D, &00, &00, &00, &00, &00, &00, &00, &00, &00, &0D, &80, &05, &05, &05, &05, &05, &05, &80, &00, &00, &F6, &80, &80, &00, &00, &00, &01, &F6, &F6, &F6, &03, &03, &03, &64, &FD, &00, &F9, &80, &14, &00, &00, &00, &80, &00, &00, &00, &01, &1E, &1E, &80, &00, &00, &FE, &80, &80, &00, &00, &00, &01, &14, &0A, &05, &02, &02, &02, &01, &00, &00, &FF, &80, &80, &00, &00, &00 |
Plot a spriteCopy sprite sprite_number to the screen with its top-left corner at byte column plot_x, pixel row plot_y. The four sprite tables, indexed by sprite number, give the address of its data and its size: sprite_width bytes across (two MODE 2 pixels to a byte) by sprite_height pixel rows. The data is stored row by row and is written over the screen contents without masking, so a sprite's black pixels erase what was there, and there is no clipping. The screen is laid out like MODE 2 with 640-byte character rows from &3000, so successive bytes of a sprite row are 8 bytes apart, and each pixel row starts one byte below the last, or 640-7 bytes on when it crosses into the next character row. screen_ptr walks across each row, row_start_ptr remembers where the row began, and sprite_data_ptr walks through the data; Y stays 0. sprite_width and sprite_height are left holding the sprite's size.
|
|||||||||||||||
| 0900 | .plot_sprite←21← 042E JSR← 043D JSR← 0F79 JSR← 15CD JSR← 1DAA JSR← 1E20 JSR← 1E7D JSR← 20CA JSR← 7276 JSR← 7286 JSR← 72CF JSR← 72DF JSR← 72EF JSR← 72FF JSR← 7613 JSR← 7838 JSR← 7842 JSR← 78AA JSR← 78C4 JSR← 78DE JSR← 78F8 JSR | ||||||||||||||
| LDX sprite_number ; X = sprite number, indexing the four sprite tables | |||||||||||||||
| 0902 | LDA sprite_addr_lo,x ; Point sprite_data_ptr at the sprite's data... | ||||||||||||||
| 0905 | STA sprite_data_ptr ; ...its low byte from sprite_addr_lo | ||||||||||||||
| 0907 | LDA sprite_addr_hi,x ; ...high byte from its own table | ||||||||||||||
| 090A | STA sprite_data_ptr_hi ; ...so sprite_data_ptr walks through the data | ||||||||||||||
| 090C | LDA sprite_widths,x ; Bytes in each sprite row... | ||||||||||||||
| 090F | STA sprite_width ; ...counted across each row | ||||||||||||||
| 0911 | LDA sprite_heights,x ; Pixel rows in the sprite... | ||||||||||||||
| 0914 | STA sprite_height ; ...counted down the sprite | ||||||||||||||
| 0916 | JSR screen_address ; screen_ptr = address of the top-left byte | ||||||||||||||
| 0919 | LDY #0 ; Index stays 0: the pointers themselves advance | ||||||||||||||
| 091B | LDX sprite_height ; X counts the pixel rows still to plot | ||||||||||||||
| 091D | .plot_sprite_row←1← 0964 BNE | ||||||||||||||
| LDA screen_ptr ; Remember where this pixel row starts... | |||||||||||||||
| 091F | STA row_start_ptr ; ...its low byte... | ||||||||||||||
| 0921 | LDA screen_ptr_hi ; ...and its high byte... | ||||||||||||||
| 0923 | STA row_start_ptr_hi ; ...in row_start_ptr, to step down from later | ||||||||||||||
| 0925 | TXA ; Save the row count | ||||||||||||||
| 0926 | PHA ; ...on the stack: X now counts bytes | ||||||||||||||
| 0927 | LDX sprite_width ; X counts the bytes across this row | ||||||||||||||
| 0929 | .plot_sprite_byte←1← 093F BNE | ||||||||||||||
| LDA (sprite_data_ptr),y ; Copy one sprite byte... | |||||||||||||||
| 092B | STA (screen_ptr),y ; ...to the screen, over whatever was there | ||||||||||||||
| 092D | CLC ; Step screen_ptr right one byte column: 8 bytes on | ||||||||||||||
| 092E | LDA screen_ptr ; ...the screen address's low byte... | ||||||||||||||
| 0930 | ADC #8 ; ...+ 8, the next byte column... | ||||||||||||||
| 0932 | STA screen_ptr ; ...as screen_ptr's new low byte | ||||||||||||||
| 0934 | BCC plot_sprite_next_data ; No carry: the high byte stands | ||||||||||||||
| 0936 | INC screen_ptr_hi ; ...with carry into the high byte | ||||||||||||||
| 0938 | .plot_sprite_next_data←1← 0934 BCC | ||||||||||||||
| INC sprite_data_ptr ; Next sprite data byte | |||||||||||||||
| 093A | BNE plot_sprite_count_byte ; No carry: the high byte stands | ||||||||||||||
| 093C | INC sprite_data_ptr_hi ; ...with carry into the high byte | ||||||||||||||
| 093E | .plot_sprite_count_byte←1← 093A BNE | ||||||||||||||
| DEX ; One byte fewer left in this row | |||||||||||||||
| 093F | BNE plot_sprite_byte ; More of the row: plot the next byte | ||||||||||||||
| 0941 | CLC ; screen_ptr = row start + 1: the next pixel row down | ||||||||||||||
| 0942 | LDA row_start_ptr ; The row start's low byte... | ||||||||||||||
| 0944 | ADC #1 ; ...+ 1, one pixel row lower... | ||||||||||||||
| 0946 | STA screen_ptr ; ...is the new low byte | ||||||||||||||
| 0948 | LDA row_start_ptr_hi ; The row start's high byte... | ||||||||||||||
| 094A | ADC #0 ; ...plus the carry... | ||||||||||||||
| 094C | STA screen_ptr_hi ; ...is the new high byte | ||||||||||||||
| 094E | LDA screen_ptr ; Has it crossed into the next character row? | ||||||||||||||
| 0950 | AND #7 ; ...(pixel row within the character now 0) | ||||||||||||||
| 0952 | BNE plot_sprite_next_row ; No: still within the character row | ||||||||||||||
| 0954 | CLC ; Yes: add &278 more, to the top of the character... | ||||||||||||||
| 0955 | LDA screen_ptr ; ...row below (row start + 1 + &278 = + 640 - 7) | ||||||||||||||
| 0957 | ADC #&78 ; ...low byte + &78 (640 - 8 = &278)... | ||||||||||||||
| 0959 | STA screen_ptr ; ...as screen_ptr's low byte | ||||||||||||||
| 095B | LDA screen_ptr_hi ; ...then the high byte... | ||||||||||||||
| 095D | ADC #2 ; ...+ 2 and the carry... | ||||||||||||||
| 095F | STA screen_ptr_hi ; ...as screen_ptr's high byte: the row below | ||||||||||||||
| 0961 | .plot_sprite_next_row←1← 0952 BNE | ||||||||||||||
| PLA ; Recover the row count | |||||||||||||||
| 0962 | TAX ; ...back into X | ||||||||||||||
| 0963 | DEX ; One pixel row fewer to plot | ||||||||||||||
| 0964 | BNE plot_sprite_row ; More rows: plot the next | ||||||||||||||
| 0966 | RTS ; Return: the sprite is on the screen | ||||||||||||||
Calculate a screen addressSet screen_ptr to the screen address of byte column plot_x on pixel row plot_y: &3000 + 640 x (plot_y DIV 8) + (plot_y MOD 8) + 8 x plot_x. plot_sprite calls it once per sprite, for the top-left byte. The multiplication by 640 is done with a table inside MOS 1.20 (mos_row_offsets, two bytes per character row, high byte first), so this only works with that MOS. The high byte of 8 x plot_x is plot_x DIV 32, taken from plot_x's top three bits with four ROLs.
|
|||||||||||||||
| 0967 | .screen_address←1← 0916 JSR | ||||||||||||||
| LDA plot_y ; Table index = 2 x (plot_y DIV 8), the character row... | |||||||||||||||
| 0969 | LSR ; ...plot_y DIV 2... | ||||||||||||||
| 096A | LSR ; ...plot_y DIV 4: 2 x the character row, + plot_y bit 2... | ||||||||||||||
| 096B | AND #&fe ; ...bit 0 cleared: the row's pair of table bytes | ||||||||||||||
| 096D | TAY ; ...as the index into the row table | ||||||||||||||
| 096E | LDA mos_row_offsets,y ; High byte of row x 640, from the MOS table... | ||||||||||||||
| 0971 | CLC ; ...(carry clear for the add) | ||||||||||||||
| 0972 | ADC #>(screen_start) ; ...plus &30: the screen starts at &3000 | ||||||||||||||
| 0974 | STA screen_ptr_hi ; ...as the screen address high byte | ||||||||||||||
| 0976 | LDA mos_row_offsets_lo,y ; Low byte of row x 640 | ||||||||||||||
| 0979 | STA screen_ptr ; ...as the low byte | ||||||||||||||
| 097B | LDA plot_y ; Add the pixel row within the character... | ||||||||||||||
| 097D | AND #7 ; ...plot_y MOD 8... | ||||||||||||||
| 097F | ADC screen_ptr ; ...(carry clear: adding &30 to the high byte cannot carry) | ||||||||||||||
| 0981 | STA screen_ptr ; ...stored in the low byte | ||||||||||||||
| 0983 | CLC ; Add 8 x plot_x: its high byte is plot_x DIV 32... | ||||||||||||||
| 0984 | LDA plot_x ; ...taking the byte column... | ||||||||||||||
| 0986 | AND #&e0 ; ...bits 7-5 kept... | ||||||||||||||
| 0988 | ROL ; ...four ROLs through the carry: bit 7 out... | ||||||||||||||
| 0989 | ROL ; ...bit 7 in at bit 0, bit 6 out | ||||||||||||||
| 098A | ROL ; ...bits 7-6 at bits 1-0, bit 5 out | ||||||||||||||
| 098B | ROL ; ...bits 7-5 now in bits 2-0 | ||||||||||||||
| 098C | CLC ; ...(carry clear for the add) | ||||||||||||||
| 098D | ADC screen_ptr_hi ; ...added to the high byte | ||||||||||||||
| 098F | STA screen_ptr_hi ; ...as screen_ptr's high byte | ||||||||||||||
| 0991 | LDA plot_x ; Low byte + (plot_x x 8) AND &FF: plot_x... | ||||||||||||||
| 0993 | ASL ; ...x 2... | ||||||||||||||
| 0994 | ASL ; ...x 4... | ||||||||||||||
| 0995 | ASL ; ...x 8, its top bits dropping out | ||||||||||||||
| 0996 | CLC ; ...(carry clear for the add) | ||||||||||||||
| 0997 | ADC screen_ptr ; ...added to the low byte | ||||||||||||||
| 0999 | STA screen_ptr ; ...as screen_ptr's low byte | ||||||||||||||
| 099B | BCC screen_address_done ; No carry: done | ||||||||||||||
| 099D | INC screen_ptr_hi ; ...with carry into the high byte | ||||||||||||||
| 099F | .screen_address_done←1← 099B BCC | ||||||||||||||
| RTS ; Return with screen_ptr set | |||||||||||||||
| 09A0 | EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &FF, &FF, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 ; Not referenced | ||||||||||||||
| ; The exit's map x, kept while a hero goes down it. | |||||||||||||||
| 09F0 | .exit_saved_x←4← 1F7A STA← 1FA7 LDA← 1FD3 LDA← 2026 LDA | ||||||||||||||
| EQUB &04 | |||||||||||||||
| ; The exit's map y, kept while a hero goes down it. | |||||||||||||||
| 09F1 | .exit_saved_y←4← 1F80 STA← 1FAD LDA← 1FD9 LDA← 202C LDA | ||||||||||||||
| EQUB &2C | |||||||||||||||
| ; Non-zero while a hero is going down the exit. | |||||||||||||||
| 09F2 | .exit_busy←5← 14AD STA← 1F10 LDA← 1F96 LDA← 2034 STA← 2078 STA | ||||||||||||||
| EQUB &00 | |||||||||||||||
| ; Direction (1, 3, 5, 7) of the hero spinning on the exit. | |||||||||||||||
| 09F3 | .exit_spin←5← 1FBE LDA← 1FC3 STA← 1FCE ADC← 1FF4 STA← 2086 STA | ||||||||||||||
| EQUB &FF | |||||||||||||||
| ; Spins left before the hero has gone (4 to 1). | |||||||||||||||
| 09F4 | .exit_shrinks_left←3← 1FDF LDX← 1FF7 DEC← 208B STA | ||||||||||||||
| EQUB &00 | |||||||||||||||
| ; The hero going down the exit. | |||||||||||||||
| 09F5 | .exiting_hero←3← 1F9E LDX← 1FBA LDX← 207E STA | ||||||||||||||
| EQUB &03 | |||||||||||||||
| ; Horizontal offset of the shrinking hero, in byte columns, ; entries 1-4 by exit_shrinks_left. Entry 0 is written at &2040 ; and never read. | |||||||||||||||
| 09F6 | .exit_offsets_x←2Referenced by← 2042 STAUsed as index base by← 1FE2 LDA | ||||||||||||||
| EQUB &04 | |||||||||||||||
| ; exit_offsets_x entry 1. | |||||||||||||||
| 09F7 | .exit_offset_x_1←1← 14BE STA | ||||||||||||||
| EQUB &01 | |||||||||||||||
| ; exit_offsets_x entry 2. | |||||||||||||||
| 09F8 | .exit_offset_x_2←1← 14C1 STA | ||||||||||||||
| EQUB &01 | |||||||||||||||
| ; exit_offsets_x entry 3. | |||||||||||||||
| 09F9 | .exit_offset_x_3←1← 14B0 STA | ||||||||||||||
| EQUB &00 | |||||||||||||||
| ; Vertical offset of the shrinking hero, in pixel rows, entries ; 1-4 by exit_shrinks_left (at exit_offsets_y+1 to +4). Also ; entry 4 of exit_offsets_x. | |||||||||||||||
| 09FA | .exit_offsets_y←2Referenced by← 14B3 STAUsed as index base by← 1FE7 LDA | ||||||||||||||
| EQUB &00 | |||||||||||||||
| ; exit_offsets_y entry 1. | |||||||||||||||
| 09FB | .exit_offset_y_1←1← 14CE STA | ||||||||||||||
| EQUB &05 | |||||||||||||||
| ; exit_offsets_y entry 2. | |||||||||||||||
| 09FC | .exit_offset_y_2←1← 14D3 STA | ||||||||||||||
| EQUB &03 | |||||||||||||||
| ; exit_offsets_y entry 3. | |||||||||||||||
| 09FD | .exit_offset_y_3←1← 14C4 STA | ||||||||||||||
| EQUB &01 | |||||||||||||||
| ; exit_offsets_y entry 4. | |||||||||||||||
| 09FE | .exit_offset_y_4←1← 14B6 STA | ||||||||||||||
| EQUB &00 | |||||||||||||||
| ; The hero whose sprites are shrunk, or &FF. | |||||||||||||||
| 09FF | .shrunk_hero←4← 14C9 STA← 1F2D LDX← 2045 LDX← 2081 STA | ||||||||||||||
| EQUB &FF | |||||||||||||||
| ; Data of sprite &5F: 4 bytes x 12 rows. | |||||||||||||||
| 0A00 | .sprite_boots | ||||||||||||||
| EQUB &00, &00, &00, &00, &00, &00, &00, &15, &00, &00, &00, &3F, &00, &00, &00, &3F, &00, &01, &13, &2A, &00, &01, &13, &2A, &00, &01, &13, &00, &00, &03, &13, &00, &03, &03, &33, &00, &03, &03, &33, &00, &03, &03, &33, &00, &00, &00, &00, &00 | |||||||||||||||
| ; Data of sprite &60: 4 bytes x 12 rows. | |||||||||||||||
| 0A30 | .sprite_helmet | ||||||||||||||
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &2A, &3C, &22, &2A, &2A, &3C, &22, &2A, &2A, &3C, &22, &2A, &14, &14, &11, &00, &14, &00, &11, &00, &14, &28, &39, &00, &14, &3C, &33, &00, &14, &3C, &33, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |||||||||||||||
| ; Data of sprite &61: 4 bytes x 12 rows. | |||||||||||||||
| 0A60 | .sprite_potion | ||||||||||||||
| EQUB &00, &00, &00, &00, &00, &01, &02, &00, &00, &15, &2A, &00, &00, &05, &02, &00, &00, &05, &02, &00, &00, &05, &02, &00, &00, &05, &02, &00, &00, &0F, &03, &00, &05, &0F, &0B, &02, &05, &0F, &0B, &02, &05, &0F, &03, &02, &00, &0F, &03, &00 | |||||||||||||||
| ; Data of sprite &63: 4 bytes x 12 rows. | |||||||||||||||
| 0A90 | .sprite_magic_sword | ||||||||||||||
| EQUB &00, &00, &00, &00, &00, &54, &00, &54, &00, &00, &00, &00, &54, &00, &04, &00, &00, &00, &04, &00, &3F, &3F, &2E, &0C, &15, &3F, &2E, &00, &00, &00, &04, &54, &A8, &00, &00, &00, &00, &54, &00, &00, &00, &00, &00, &A8, &00, &00, &00, &00 | |||||||||||||||
| ; Data of sprite &62: 4 bytes x 12 rows. | |||||||||||||||
| 0AC0 | .sprite_weapons | ||||||||||||||
| EQUB &2A, &00, &00, &02, &05, &00, &00, &02, &00, &0A, &15, &01, &00, &04, &1D, &01, &01, &04, &15, &01, &05, &00, &15, &01, &05, &00, &15, &02, &05, &00, &15, &02, &00, &15, &15, &00, &02, &2A, &33, &22, &01, &00, &11, &00, &02, &02, &11, &00 | |||||||||||||||
| ; Data of sprite &2A: 4 bytes x 12 rows. | |||||||||||||||
| 0AF0 | .sprite_cross | ||||||||||||||
| EQUB &00, &0F, &02, &00, &00, &0F, &02, &00, &00, &1F, &02, &00, &3F, &1F, &0F, &02, &0F, &1F, &0F, &02, &0F, &1F, &0F, &02, &00, &0F, &02, &00, &00, &0F, &02, &00, &00, &2F, &02, &00, &00, &2F, &02, &00, &00, &0F, &02, &00, &00, &0F, &02, &00 | |||||||||||||||
| ; Number of missiles each hero may have in flight at once, 1-3 ; (raised by a pile of weapons). | |||||||||||||||
| 0B20 | .hero_max_missiles←9Used as index base by← 0ED2 STA← 0F2B LDA← 0F30 ADC← 6F22 ADC← 751A INC← 751D LDA← 7526 STA← 75C5 LDA← 75CA ADC | ||||||||||||||
| EQUB &03, &02, &01, &03 | |||||||||||||||
| ; INKEY key numbers of the magic keys of heroes 0 and 1, the ; only heroes with magic. | |||||||||||||||
| 0B24 | .hero_magic_key←1Used as index base by← 7624 LDA | ||||||||||||||
| EQUB &FE, &B6 | |||||||||||||||
| ; Frames until heroes 0 and 1 next check their magic key. | |||||||||||||||
| 0B26 | .hero_magic_delay←3Used as index base by← 7619 DEC← 7621 STA← 7644 STA | ||||||||||||||
| EQUB &01, &01 | |||||||||||||||
| ; Monsters killed by the magic being cast, each worth a point. | |||||||||||||||
| 0B28 | .magic_kill_count←3← 765E STA← 768F INC← 7699 LDY | ||||||||||||||
| EQUB &00, &10 | |||||||||||||||
| ; Queue of heroes waiting to come back: each entry is a hero ; number plus 1, or &64 for a slot that brings nobody back; 0 ; ends the queue. A Cross of Resurrection takes the first entry. | |||||||||||||||
| 0B2A | .returning_hero_queue←9Referenced by← 7421 LDA← 742B LDX← 7432 STAUsed as index base by← 06EC STA← 159C STA← 16B4 LDA← 16BB STA← 7256 LDA← 725F STA | ||||||||||||||
| EQUB &03, &02, &01, &04, &10 | |||||||||||||||
| ; Index (0-7) of the trapdoor from which the next monster ; emerges. | |||||||||||||||
| 0B2F | .next_trapdoor←5← 14B9 STA← 7CB3 INC← 7CB6 LDA← 7CBF STA← 7CC2 LDY | ||||||||||||||
| EQUB &04 | |||||||||||||||
| ; Sprites of a hero dying, in order (sparkles &16-&19, then ; skulls &64-&68, ending as the skull left where the hero fell), ; or returning, in reverse. | |||||||||||||||
| 0B30 | .hero_appearance_sprites←1Used as index base by← 76F2 LDA | ||||||||||||||
| EQUB &16, &17, &18, &19 | |||||||||||||||
| 0B34 | EQUS "defgh" | ||||||||||||||
| 0B39 | EQUB &10, &10, &10, &10, &10, &10, &10 ; Not referenced | ||||||||||||||
| ; Hit points left for each monster (entries 1-30); a hit ; subtracts the missile's damage. | |||||||||||||||
| 0B40 | .monster_hit_points←4Used as index base by← 1592 STA← 758D LDA← 759E STA← 75A6 STA | ||||||||||||||
| EQUB &10, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &05, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &08, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10 | |||||||||||||||
| ; Damage each hero's missiles do, 1-9 (raised by a magic sword). | |||||||||||||||
| 0B70 | .hero_missile_damage←7Used as index base by← 0ED8 STA← 0F50 LDA← 6F4A LDA← 756B INC← 756E LDA← 7577 STA← 75EE LDA | ||||||||||||||
| EQUB &02, &03, &09, &03, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10 | |||||||||||||||
| ; Damage each missile in flight will do (12 slots, three per ; hero). | |||||||||||||||
| 0B80 | .missile_damage←3Used as index base by← 6F4D STA← 71F0 LDA← 7591 SBC | ||||||||||||||
| EQUB &02, &02, &02, &03, &03, &04, &09, &09, &10, &03, &03, &03, &10, &10, &10, &10 | |||||||||||||||
| ; Map x of the level's eight trapdoors, from the level file. | |||||||||||||||
| 0B90 | .trapdoor_x←2Used as index base by← 1554 STA← 7CC5 LDA | ||||||||||||||
| EQUB &0B, &15, &17, &10, &03, &17, &0D, &1A | |||||||||||||||
| ; Map y of the level's eight trapdoors, from the level file. | |||||||||||||||
| 0B98 | .trapdoor_y←2Used as index base by← 155A STA← 7CCB LDA | ||||||||||||||
| EQUB &04, &0C, &14, &1D | |||||||||||||||
| 0B9C | EQUS "% (," | ||||||||||||||
| ; Score hundreds digit, as a digit sprite (&1E-&27 for 0-9). | |||||||||||||||
| 0BA0 | .hero_score_hundreds←5Used as index base by← 0EE6 STA← 72AA INC← 72AD LDA← 72B6 STA← 72D4 LDA | ||||||||||||||
| EQUB &1E, &1E, &1E, &1E | |||||||||||||||
| ; Score tens digit, as a digit sprite. | |||||||||||||||
| 0BA4 | .hero_score_tens←5Used as index base by← 0EE9 STA← 729B INC← 729E LDA← 72A7 STA← 72E4 LDA | ||||||||||||||
| EQUB &1E, &1E, &1E, &1E | |||||||||||||||
| ; Score units digit, as a digit sprite. | |||||||||||||||
| 0BA8 | .hero_score_units←7Used as index base by← 06E2 DEC← 0EEE STA← 728C INC← 728F LDA← 7298 STA← 72F4 LDA← 74CF LDA | ||||||||||||||
| EQUB &1D, &1D, &1D, &1D | |||||||||||||||
| ; Score thousands digit, as a digit sprite. | |||||||||||||||
| 0BAC | .hero_score_thousands←5Used as index base by← 0400 INC← 0403 LDA← 040C STA← 0EE3 STA← 72C8 LDA | ||||||||||||||
| EQUB &1E, &1E, &1E, &1E, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10, &10 | |||||||||||||||
| ; OSWORD 7 (SOUND) parameter block for teleporting. | |||||||||||||||
| 0BF0 | .teleport_sound | ||||||||||||||
| EQUW &13, &04, ; SOUND channel 3 (flush), envelope 4, pitch 100, 30 ; 100, duration 30 | |||||||||||||||
| ; OSWORD 7 (SOUND) parameter block for eating food, and (with ; its pitch changed) opening a door. | |||||||||||||||
| 0BF8 | .food_sound | ||||||||||||||
| EQUW &13, &02, ; SOUND channel 3 (flush), envelope 2, pitch 200, 2 ; 200, duration 2 | |||||||||||||||
| ; The level's wall map, from the level file: eight bytes per ; room, one per row of cells, one bit per cell (bit 7 at the ; left). Rooms are 8x8 cells and run four to a row of the map. ; The first eight bytes are also the MOS 1.20 definition of ; character 128, which the WRCHV handler overwrites with each ; glyph it prints; the level is unpacked only after the level ; number has been printed. | |||||||||||||||
| 0C00 | .room_walls←3Used as index base by← 1567 STA← 7FC8 STA← 7FEB STA | ||||||||||||||
| EQUB &54, &49, &4B, &50, &24, &55, ; Not read: unpack_level &54, &48, &4F, &5B, &4B, &46, ; copies each level's &2C, &44, &5D, &2F ; wall map here | |||||||||||||||
| 0C10 | EQUB &44, &59, &57, &33, &43, &5A, &44, &5C, &38, &56, &5C, &3B, &56, &48, &52, &56 ; ...entries 16-31, not read | ||||||||||||||
| 0C20 | EQUB &61, &6F, &02, &62, &72, &6C, &75, &07, &00, &6A, &03, &0B, &1D, &14, &16, &19 ; ...entries 32-47, not read | ||||||||||||||
| 0C30 | EQUB &10, &70, &67, &74, &61, &66, &62, &19, &71, &19, &72, &7A, &6A, &78, &1E, &78 ; ...entries 48-63, not read | ||||||||||||||
| 0C40 | EQUB &09, &17, &07, &0D, &64, &0B, &09, &05, &07, &0D, &13, &6B, &1C, &08, &1C, &02 ; ...entries 64-79, not read | ||||||||||||||
| 0C50 | EQUB &19, &02, &01, &1A, &1B, &1B, &76, &03, &17, &79, &17, &1A, &0E, &16, &1B, &0B ; ...entries 80-95, not read | ||||||||||||||
| 0C60 | EQUB &40, &35, &2A, &2A, &37, &45, &21, &26, &25, &2C, &4A, &32, &29, &39, &4E, &2E ; ...entries 96-111, not read | ||||||||||||||
| 0C70 | EQUB &3E, &35, &52, &32, &3A, &2C, &56, &38, &36, &3C, &5A, &29, &39, &3C, &3A, &36 ; ...entries 112-127, not read | ||||||||||||||
| 0C80 | EQUB &CE, &C6, &A2, &D7, &CC, &CC, &D5, &A7, &C1, &DA, &AA, &CA, &AC, &CB, &A4, &A5 ; ...entries 128-143, not read | ||||||||||||||
| 0C90 | EQUB &BA, &BB, &B8, &D4, &B4, &D7, &BC, &BD, &B2, &B3, &B0, &DF, &BC, &D4, &D8, &BF ; ...entries 144-159, not read | ||||||||||||||
| 0CA0 | EQUB &F4, &E9, &E7, &FA, &84, &E4, &F4, &E2, &88, &EA, &E5, &E5, &FF, &E4, &EA, &EA ; ...entries 160-175, not read | ||||||||||||||
| 0CB0 | EQUB &E2, &F8, &FC, &F4, &94, &F0, &E4, &F6, &EB, &F0, &F4, &FC, &9C, &E9, &F6, &F6 ; ...entries 176-191, not read | ||||||||||||||
| 0CC0 | EQUB &93, &E1, &8F, &86, &97, ; ...entries 192-200, not &96, &87, &80, &8D ; read | ||||||||||||||
| 0CC9 | EQUB &E7, &9E, &83, &8D, &83, &85, &90 ; Not referenced | ||||||||||||||
| ; Health each hero loses when a monster touches it, 3-9 (lowered ; by a magic helmet). The status panel shows 10 minus this as ; the armour rating. | |||||||||||||||
| 0CD0 | .hero_damage_taken←7Used as index base by← 0EDE STA← 0F1E SBC← 74EF DEC← 74F2 LDA← 74F9 INC← 75BD SBC← 79A7 LDY | ||||||||||||||
| EQUB &89, &9E, &87, &F3, &95, &9B, &92, &F7, &90, &98, &8A, &8B, &85, &FD, &9A, &8A, &AE, &A6, &A7, &AC, &AA, &AC, &A8, &A0, &C9, &00, &00, &00, &00, &00, &00, &00 | |||||||||||||||
| ; OSWORD 7 (SOUND) parameter block for a monster hit, and ; (louder) touching an energy drainer. | |||||||||||||||
| 0CF0 | .hit_sound | ||||||||||||||
| EQUW &10, &01, 6, ; SOUND channel 0 (flush), envelope 1, 6 ; pitch 6, duration 6 | |||||||||||||||
| 0CF8 | EQUB &12, &00, &03, &00, ; Not referenced &C8, &00, &0A, &00 | ||||||||||||||
Load the last game file and start the game (not used)The cassette's last loading step, kept with the rest of its page &0D. On the cassette, Dunjunz1 jumps here to build an OSFILE control block at &0D80 naming core_filename ("Dunjunz5") with load address &00002000, call the filing system's FILEV handler directly, as boot_loader does, to load the game's &2000-&2FFF over Dunjunz1, and fall into game_entry. Nothing in this release runs it: DUNK's loader enters the game at game_entry. The bytes are as the cassette's run leaves them: the JSR's stored operand is &F27D, the MOS 1.20 FILEV handler for the cassette and ROM filing systems, and core_osfile_block holds the block it built, so the image was saved after load_core had run. Like game_entry, this lies in page &0D, the per-level workspace that reset_workspace overwrites at the start of every level, so the labels of that workspace fall inside these instructions, and core_filename (&0D70) and core_osfile_block (&0D80) share their addresses with hero_key_up and hero_key_fire.
|
||||
| ; General-purpose scratch byte. | ||||
| ; Second scratch byte. | ||||
| 0D00 | .scratch←50Referenced by← 1CC5 STX← 1D00 LDX← 1D4E STA← 1D52 ADC← 1D55 ADC← 1D58 ADC← 1D77 STA← 1D82 AND← 2006 STA← 200D CPX← 201E CPX← 205A STA← 2063 CPY← 2070 CPY← 6F19 STA← 6F1E ADC← 6F25 STA← 6F71 CPY← 6FD7 STA← 7002 STX← 7007 CPY← 713C STA← 74B6 STA← 74C3 LDA← 74D8 LDA← 77E6 STA← 782C LDA← 7857 STA← 785B ADC← 785E ADC← 7861 ADC← 7886 STA← 788B ADC← 7901 STA← 7905 ADC← 7908 ADC← 790B ADC← 7926 STA← 7931 AND← 793D STA← 7941 ADC← 7944 ADC← 7947 ADC← 7962 STA← 796D AND← 7976 CPX← 7990 LDA← 7A89 STA← 7CE3 STXUsed as index base by← 14A5 STA | |||
| .load_core←50Referenced by← 1CC5 STX← 1D00 LDX← 1D4E STA← 1D52 ADC← 1D55 ADC← 1D58 ADC← 1D77 STA← 1D82 AND← 2006 STA← 200D CPX← 201E CPX← 205A STA← 2063 CPY← 2070 CPY← 6F19 STA← 6F1E ADC← 6F25 STA← 6F71 CPY← 6FD7 STA← 7002 STX← 7007 CPY← 713C STA← 74B6 STA← 74C3 LDA← 74D8 LDA← 77E6 STA← 782C LDA← 7857 STA← 785B ADC← 785E ADC← 7861 ADC← 7886 STA← 788B ADC← 7901 STA← 7905 ADC← 7908 ADC← 790B ADC← 7926 STA← 7931 AND← 793D STA← 7941 ADC← 7944 ADC← 7947 ADC← 7962 STA← 796D AND← 7976 CPX← 7990 LDA← 7A89 STA← 7CE3 STXUsed as index base by← 14A5 STA | ||||
| LDA #<(core_filename) ; Filename address: core_filename... | ||||
| ; Map x of the cell being drawn, tested or moved to. ; plot_at_cell replaces it with the pixel offset within the ; room. | ||||
| ; Map y of the cell being drawn, tested or moved to. ; plot_at_cell replaces it with the pixel offset within the ; room. | ||||
| ; Room of the cell being drawn, as an offset into room_walls. | ||||
| 0D02 | .cell_x←59← 119C STA← 11F4 STA← 1CCB STA← 1CDB CMP← 1D26 LDA← 1D3C STA← 1D5D LDA← 1D6C LDA← 1DD1 STA← 1E38 STA← 1E48 CMP← 1F58 STA← 1FAA STA← 1FD6 STA← 2094 STA← 20A7 LDA← 20DE INC← 20E9 DEC← 20FA DEC← 6FA7 STA← 700F CMP← 707C STA← 70AA STA← 70EE STA← 7120 STA← 715B STA← 7176 CMP← 71E3 CMP← 7310 STA← 732C STA← 733A CMP← 73F0 STA← 752F STA← 766A STA← 777D STA← 779B STA← 77AD STA← 77BF STA← 77D1 STA← 7801 STA← 7820 LDA← 7867 LDA← 7872 LDA← 787C STA← 789E ADC← 78B8 ADC← 78D2 ADC← 78EC ADC← 7910 LDA← 791D LDA← 794C LDA← 7959 LDA← 797B LDA← 7997 LDA← 79D0 STA← 79EA STA← 7A48 STA← 7B07 STA← 7B44 STA | |||
| STA core_osfile_block ; ...into the block's bytes 0-1, low byte... | ||||
| ; Map x of the creature being moved, before the move. | ||||
| 0D05 | .load_core_name_page | |||
| LDA #>(core_filename) ; ...and its page... | ||||
| ; Map y of the creature being moved, before the move. | ||||
| ; Pixel offset of the hero being moved, before the move. | ||||
| ; Pixel offset of the hero being moved, before the move. | ||||
| 0D07 | .previous_y←11← 6EA0 STA← 6F5C LDA← 6FC1 LDA← 6FEB LDA← 7027 LDA← 706F LDA← 707F LDA← 79F6 STA← 7A5E LDA← 7A9B LDA← 7AFE LDA | |||
| STA core_osfile_block + 1 ; ...into byte 1 | ||||
| 0D0A | LDA #0 ; Load address &00002000... | |||
| 0D0C | STA core_osfile_block + 2 ; ...byte 2 is 0... | |||
| ; Map x of each hero. | ||||
| 0D0F | .load_core_load_page | |||
| LDA #&20 ; ...byte 3 is &20... | ||||
| 0D11 | STA core_osfile_block + 3 ; ...the game's &2000-&2FFF, over Dunjunz1 | |||
| ; Map y of each hero. | ||||
| 0D14 | .load_core_block_address | |||
| LDX #<(core_osfile_block) ; X, Y = core_osfile_block... | ||||
| 0D16 | LDY #>(core_osfile_block) ; ...its page | |||
| 0D18 | LDA #0 ; ...bytes 4 and 5 are 0... | |||
| ; Direction each hero faces: 1 up, 3 right, 5 down, 7 left; 0 ; when the hero is not in play. | ||||
| 0D1A | .hero_direction←18Used as index base by← 06D0 STA← 1DE6 LDA← 1F52 STA← 6E82 LDA← 6ECB STA← 6EDE STA← 6EF1 STA← 6F04 STA← 6F2D LDA← 6F79 LDA← 701C LDA← 7097 LDA← 7221 LDA← 7249 STA← 7452 STA← 7711 STA← 7B67 LDA← 7BAF LDA | |||
| STA core_osfile_block + 4 ; ...byte 4... | ||||
| 0D1D | STA core_osfile_block + 5 ; ...and byte 5: the I/O processor | |||
| ; Animation frame of each hero (0 or 1), added to its sprite. | ||||
| 0D20 | .hero_frame←14Referenced by← 774E LDA← 7753 STAUsed as index base by← 06DA STA← 1DF3 LDA← 6F62 LDA← 6F67 STA← 709C ADC← 7457 STA← 76EE LDA← 76FF LDA← 771F STA← 772E STA← 7BA2 LDA← 7BA7 STA | |||
| LDA filev ; Copy FILEV into the JSR below... | ||||
| ; Frames left in each hero's step between cells. | ||||
| 0D23 | .load_core_store_filev←2← 7771 LDA← 7776 STA | |||
| STA load_core_call_address ; ...its low byte... | ||||
| 0D26 | LDA filev + 1 ; ...and its high byte... | |||
| ; Each hero's horizontal pixel offset while between cells. | ||||
| 0D29 | .load_core_store_filev_high | |||
| STA load_core_call_address + 1 ; ...so the JSR calls the filing system's routine | ||||
| 0D2C | LDA #&ff ; A = &FF: load the file | |||
| ; Operand of the JSR at load_core_call. Stored as &F27D, the ; FILEV handler that load_core copied there when the cassette ; ran it. | ||||
| ; Each hero's vertical pixel offset while between cells. | ||||
| 0D2E | .load_core_call | |||
| JSR &f27d ; Load Dunjunz5, then fall into game_entry | ||||
| fall through ↓ | ||||
Start the gameThe game's entry point, where the release's loader jumps once the game is in memory. It prepares the two MOS services the game leans on: First the bell (the BEL character's channel, envelope, pitch and duration, through OSBYTEs &D3-&D6): the bell is what sounds when a hero fires, and the victory sequence raises its pitch. Then the text: save the MOS's WRCHV in saved_wrchv, for draw_view_frames to put back while it sends the view frames' PLOT commands, and point WRCHV at wrch_handler, so that all the game's text is printed in its own font. This code lives in the per-level workspace: from &0D40 its bytes are the missile tables and other workspace in page &0D, which reset_workspace overwrites from workspace_template at the start of every level, so it can run only before the first level after the game is loaded. It does not return; what follows &0D6A, starting the game, is the release's own. |
|
| 0D31 | .game_entry |
| LDA #osbyte_bell_channel ; OSBYTE &D3: bell channel... | |
| 0D33 | LDX #&11 ; ...&11: channel 1, with SOUND's flush bit set |
| 0D35 | LDY #0 ; Y = 0: replace the setting with X |
| 0D37 | JSR osbyte ; Set it: the firing bell sounds on channel 1 osbyte: bell channel |
| 0D3A | LDA #osbyte_bell_envelope ; OSBYTE &D4: bell envelope... |
| 0D3C | LDX #0 ; ...0, a fixed amplitude |
| 0D3E | LDY #0 ; Y = 0: replace the setting with X |
| ; Map x of each missile (12 slots, three per hero). | |
| 0D40 | .missile_x←6Used as index base by← 6F3C STA← 70EB LDA← 710C INC← 711A DEC← 711D LDA← 7158 LDA |
| JSR osbyte ; Set it: BEL plays at a fixed amplitude osbyte: bell envelope | |
| 0D43 | LDA #osbyte_bell_frequency ; OSBYTE &D5: bell pitch... |
| 0D45 | LDX #&64 ; ...&64, SOUND pitch 100 |
| 0D47 | LDY #0 ; Y = 0: replace the setting with X |
| 0D49 | JSR osbyte ; Set it: BEL plays at pitch &64 osbyte: bell frequency |
| ; Map y of each missile. | |
| 0D4C | .missile_y←6Used as index base by← 6F42 STA← 70F1 LDA← 7105 DEC← 7113 INC← 7123 LDA← 715E LDA |
| LDA #osbyte_bell_duration ; OSBYTE &D6: bell duration... | |
| 0D4E | LDX #1 ; ...1, in twentieths of a second |
| 0D50 | LDY #0 ; Y = 0: replace the setting with X |
| 0D52 | JSR osbyte ; Set it: BEL lasts a twentieth of a second osbyte: bell duration |
| 0D55 | LDA wrchv ; Save the MOS's WRCHV... |
| ; 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. | |
| 0D58 | .missile_direction←12Used as index base by← 6F28 LDA← 6F36 STA← 70D2 LDA← 70DE STA← 70FE LDA← 7134 STA← 71A5 LDA← 71AE STA← 71BA STA← 71C6 STA← 71CE STA← 720C ADC |
| STA saved_wrchv ; ...its low byte into saved_wrchv... | |
| 0D5B | LDA wrchv + 1 ; ...and its high byte... |
| 0D5E | STA saved_wrchv + 1 ; ...in saved_wrchv, for drawing the view frames |
| 0D61 | LDA #<(wrch_handler) ; Point WRCHV at wrch_handler, the game's font... |
| ; Sprite base of each missile, to which its direction is added; ; also identifies the hero who fired it. | |
| 0D63 | .set_wrchv_low |
| STA wrchv ; ...into WRCHV's low byte... | |
| 0D66 | LDA #>(wrch_handler) ; ...and wrch_handler's high byte... |
| 0D68 | STA wrchv + 1 ; ...into WRCHV's: text now goes through it |
| 0D6B | JMP new_game ; Start a new game |
| 0D6E | EQUB &00, &00 ; Not referenced |
| ; INKEY key number of each hero's up key. | |
| 0D70 | .hero_key_up←1Used as index base by← 6EC1 LDA |
| .core_filename←1Used as index base by← 6EC1 LDA | |
| EQUS "Dunj" | |
| ; INKEY key number of each hero's down key. | |
| 0D74 | .hero_key_down←1Used as index base by← 6ED4 LDA |
| EQUS "unz5" | |
| ; INKEY key number of each hero's right key. | |
| 0D78 | .hero_key_right←1Used as index base by← 6EE7 LDA |
| EQUB &0D, &00, &8D, &F4 | |
| ; INKEY key number of each hero's left key. | |
| 0D7C | .hero_key_left←1Used as index base by← 6EFA LDA |
| EQUB &0D, &8D, &F5, &0D | |
| ; INKEY key number of each hero's fire key. | |
| 0D80 | .hero_key_fire←1Used as index base by← 6F0D LDA |
| .core_osfile_block←1Used as index base by← 6F0D LDA | |
| EQUB &70, &0D, ; core_osfile_block as load_core left it: &00, &20, ; core_filename (&0D70) and &00002000 &00, &00 | |
| 0D86 | EQUB &6E, &35, &0D, &18, ; Leftover: the end of "Dungeon5", &BD, &04, &0D, &69, ; a CR and a fragment of code &03, &9D |
| ; Health tens digit, as a digit sprite (&1E-&27); &1D when the ; hero is dead. | |
| 0D90 | .hero_health_tens←10Used as index base by← 06DF STA← 0E6D LDA← 7236 DEC← 7239 LDA← 726F LDA← 738E INC← 7391 LDA← 739A STA← 7506 STA← 7724 STA |
| EQUB &1D, &1D, &1D, &1D, &D0 | |
| ; Health units digit, as a digit sprite. | |
| 0D95 | .hero_health_units←7Used as index base by← 7227 DEC← 722A LDA← 7233 STA← 727B LDA← 739D STA← 750F STA← 7727 STA |
| EQUS "''''" | |
| 0D99 | EQUB &18, &BD, &08, &0D, &6D, &40, &0D ; Not referenced |
| ; 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). | |
| 0DA0 | .view_room←5Referenced by← 779E LDA← 7893 LDAUsed as index base by← 7043 LDA← 7544 STA← 767C LDA |
| EQUB &18, &0C, &68, &0C, &28, &0C, &30, &0C, &00, &00, &BD, &04, &0D, &85, &71, &8A | |
| ; Sprite base of each hero's missiles: arrows, fireballs, axes, ; swords. | |
| 0DB0 | .hero_missile_sprites←1Used as index base by← 6F50 LDA |
| EQUB &10 | |
| 0DB1 | EQUS "DLHh" |
| ; Sprite base of each hero, to which direction and frame are ; added. | |
| 0DB5 | .hero_sprites←4Used as index base by← 1FCB LDA← 1FFD LDA← 2051 LDA← 709F ADC |
| EQUB &00 | |
| 0DB6 | EQUS ",4<" |
| 0DB9 | EQUB &00, &0D, &D9 ; Not referenced |
| ; Non-zero while the hero wears Boots of Speed. | |
| 0DBC | .hero_has_boots←3Used as index base by← 7056 LDA← 7351 STA← 74E7 STA |
| EQUB &00, &00, &00, &00 | |
| ; Bit masks for the cells of a room row, left to right: &80, &40 ; ... &01. | |
| 0DC0 | .bit_masks←3Used as index base by← 1D72 LDA← 7923 LDA← 795F LDA |
| EQUB &80, &40, &20, &10, &08, &04, &02, &01, &B9, &30, &0D, &9D, &08, &0D, &4C, &D4 | |
| ; Pixel row of each hero's section of the status panel. | |
| 0DD0 | .hero_panel_y←10Used as index base by← 1D9C LDA← 1E12 LDA← 1E6D LDA← 20BC LDA← 7266 LDA← 72BD LDA← 75AF LDA← 75CF ADC← 75E7 LDA← 75FE LDA |
| EQUB &0E, &3C, &6A, &98, &E8, &E0, &04, &D0, &0A, &A2, &00, &AD, &40, &0D, &49, &01, &8D, &40, &0D, &8E, &FF, &0D, &68, &A8, &68, &AA | |
| 0DEA | EQUS "h(`" |
| 0DED | EQUB &DE, &DD, &DF, &F0, &F2, &F1, &F3, &F8, &FA, &F9, &FB, &F4, &F6, &F5, &F7, &FC ; Not referenced |
| ; Index of the last object to search when looking backwards for ; a teleporter (&1E, from workspace_template). | |
| 0DFD | .teleport_last←1← 73D3 LDY |
| EQUB &1E, &FD | |
| ; Written by draw_victory_ring; not read. | |
| 0DFF | .victory_sprite_copy←1← 1160 STA |
| EQUB &00 | |
Run the game: the menu, the levels, game overThe game's top level, from a new game to its end. The start-up code jumps here once, and every game over comes back here; it never returns. A game has three stages:
The game is won only on level 25, by reaching the Chalice: check_for_victory, called by play_level every frame, then plays the ending and resets the machine instead of returning here. |
|
| 0E00 | .new_game←2← 0D6B JMP← 0ECC JMP |
| LDA #0 ; New game: no levels played yet... | |
| 0E02 | STA level_number ; ...level_number 0, counted up by show_level_number... |
| 0E05 | STA level_bcd ; ...and level_bcd 0, counted up by level_loop |
| 0E08 | TAX ; Give each hero their starting attributes and score |
| 0E09 | .reset_each_hero←1← 0E0F BNE |
| JSR reset_hero ; Reset hero X: starting attributes, score 0000 | |
| 0E0C | INX ; Next hero, 0-3 |
| 0E0D | CPX #4 ; All four done? |
| 0E0F | BNE reset_each_hero ; No: reset the next |
| 0E11 | JSR hero_menu ; Then the players choose heroes and sound |
| ; Play each level in turn until every hero is dead. First set ; the level up: the monsters' strength, and the level number in ; decimal and in the level's filename. | |
| 0E14 | .level_loop←1← 0E84 BNE |
| LDA level_number ; Monsters' hit points: 8 + 2 x levels already played... | |
| 0E17 | ASL ; ...x 2... |
| 0E18 | CLC ; ...(carry clear for the add) |
| 0E19 | ADC #8 ; ...+ 8: 8 on the first level played... |
| 0E1B | STA monster_start_hit_points ; ...for every monster on this level |
| 0E1E | SED ; Count the level in decimal, for its filename... |
| 0E1F | CLC ; ...(carry clear for the add) |
| 0E20 | LDA level_bcd ; ...the BCD count... |
| 0E23 | ADC #1 ; ...+ 1, in decimal... |
| 0E25 | STA level_bcd ; ...is this level's number, in level_bcd |
| 0E28 | CLD ; Back to binary arithmetic |
| 0E29 | LDA level_number ; Filename digits: two once 9 levels are played |
| 0E2C | CMP #9 ; ...(show_level_number counts level_number later) |
| 0E2E | BCS two_level_digits ; Yes: two digits |
| 0E30 | LDX #0 ; X = 0: one digit |
| 0E32 | BEQ store_level_units ; Always: write the one digit |
| 0E34 | .two_level_digits←1← 0E2E BCS |
| LDX #1 ; X = 1: two digits | |
| 0E36 | .store_level_units←1← 0E32 BEQ |
| LDA level_bcd ; The level's units digit... | |
| 0E39 | AND #&0f ; ...its low nibble... |
| 0E3B | CLC ; ...(carry clear for the add)... |
| 0E3C | ADC #'0' ; ...+ '0': as an ASCII digit |
| 0E3E | STA level_filename_digits,x ; ...as the name's last digit |
| 0E41 | CPX #0 ; A two-digit name (X = 1)? |
| 0E43 | BEQ end_level_filename ; No: terminate the name |
| 0E45 | LDA level_bcd ; Yes: the tens digit... |
| 0E48 | LSR ; ...high nibble: first shift down... |
| 0E49 | LSR ; ...second shift... |
| 0E4A | LSR ; ...third shift... |
| 0E4B | LSR ; ...fourth: the tens digit |
| 0E4C | CLC ; ...(carry clear for the add)... |
| 0E4D | ADC #'0' ; ...+ '0': as an ASCII digit |
| 0E4F | STA level_filename_digits ; ...as the name's first digit |
| 0E52 | .end_level_filename←1← 0E43 BEQ |
| LDA #&0d ; Terminate the filename with a carriage return | |
| 0E54 | STA level_filename_digits + 1,x ; ...after the last digit |
| ; Set the level up on the screen and play it: the level itself, ; the status panel, the absent heroes taken out, then play_level ; until no hero is left in play. | |
| 0E57 | JSR start_level ; Load and draw the level |
| 0E5A | JSR draw_status_panel ; Draw every hero's panel section |
| 0E5D | JSR remove_absent_heroes ; Take out the heroes nobody plays |
| 0E60 | LDA #1 ; Vsync count 1: play_level's first wait is two vsyncs |
| 0E62 | STA os_vsync_counter ; ...counted down at each vertical sync |
| 0E65 | JSR play_level ; Play until no hero is left in play |
| ; The level is over. Reset every hero who died, and end the game ; if all four did. | |
| 0E68 | LDX #0 ; Count the dead, giving each their starting attributes |
| 0E6A | STX count ; ...none dead so far |
| 0E6D | .check_hero_dead←1← 0E7D BNE |
| LDA hero_health_tens,x ; Dead (heroes nobody plays count as dead)? | |
| 0E70 | CMP #spr_digit_0 - 1 ; ...health tens one below 0? |
| 0E72 | BNE next_hero_dead ; No: survived, so not reset |
| 0E74 | JSR reset_hero ; Yes: start them afresh on the next level |
| 0E77 | INC count ; ...and count them |
| 0E7A | .next_hero_dead←1← 0E72 BNE |
| INX ; Next hero, 0-3 | |
| 0E7B | CPX #4 ; All four checked? |
| 0E7D | BNE check_hero_dead ; No: next hero |
| 0E7F | LDA count ; Any hero survived? |
| 0E82 | CMP #4 ; ...fewer than four dead? |
| 0E84 | BNE level_loop ; Yes: on to the next level |
| ; Every hero is dead: print the game-over message over the ; views, then wait for a key, or for the time limit, before ; starting again. The MOS goes on counting the vsync counter ; down at every vertical sync, so if it has passed 0 by the time ; the message is printed, the wait for it to reach 0 lasts until ; it comes round, up to 256 vsyncs (about 5 s), and only then ; are keys flushed and read. | |
| 0E86 | LDA #&1c ; All dead: VDU 28,0,24,16,0, a window over the views... |
| 0E88 | JSR oswrch ; Send VDU 28 |
| 0E8B | LDA #0 ; Left column 0 |
| 0E8D | JSR oswrch ; Send the left column |
| 0E90 | LDA #&18 ; Bottom row 24 |
| 0E92 | JSR oswrch ; Send the bottom row |
| 0E95 | LDA #&10 ; Right column 16, short of the status panel |
| 0E97 | JSR oswrch ; Send the right column |
| 0E9A | LDA #0 ; Top row 0 |
| 0E9C | JSR oswrch ; Send the top row |
| 0E9F | LDA #&0c ; ...VDU 12 to clear it |
| 0EA1 | JSR oswrch ; Send VDU 12: clear the window |
| 0EA4 | LDX #4 ; Spaces over &0FF1-&0FF4, two of them the counters |
| 0EA6 | LDA #&20 ; ...the space to write |
| 0EA8 | .restore_message_spaces←1← 0EAC BNE |
| STA panel_hero - 1,x ; ...into each (&0FF1 held YOU ALL's full stop) | |
| 0EAB | DEX ; Next byte down |
| 0EAC | BNE restore_message_spaces ; Until all four are spaces |
| 0EAE | .print_game_over←1← 0EB7 BNE |
| LDA game_over_message,x ; Print game_over_message from its start (X = 0)... | |
| 0EB1 | JSR osasci ; ...through OSASCI, so each CR starts a new line |
| 0EB4 | INX ; Step to the message's next character |
| 0EB5 | CMP #0 ; ...up to its zero byte |
| 0EB7 | BNE print_game_over ; Not the end: next |
| 0EB9 | .wait_vsync_game_over←1← 0EBC BNE |
| LDA os_vsync_counter ; Wait for the vsync counter, still running, to reach 0 | |
| 0EBC | BNE wait_vsync_game_over ; Not yet: keep waiting |
| 0EBE | LDA #osbyte_flush_buffer_class ; Flush the input buffers |
| 0EC0 | JSR osbyte ; Discard keys pressed during play Flush selected class of buffer |
| 0EC3 | LDX #&70 ; Wait up to 6000 centiseconds (60 s) for a key... |
| 0EC5 | LDY #&17 ; ...&1770 centiseconds: X low, Y high |
| 0EC7 | LDA #osbyte_inkey ; OSBYTE &81: read a key within that time |
| 0EC9 | JSR osbyte ; A key, or the time running out, ends the message Read a key, waiting up to 6000 centiseconds |
| 0ECC | JMP new_game ; ...then start a new game |
Give a hero their starting attributesUndo everything hero X has gained: set their missile limit, missile damage and health lost per hit (hero_max_missiles, hero_missile_damage, hero_damage_taken) from the starting tables at &0F80, and their score to 0000 with no ten-thousands digit. It is called for every hero when a game starts, and by level_loop for each hero who died (or was not playing) when a level ends, so a dead hero comes back on the next level as new, while survivors keep their scores and the gains from objects. Health and position are not set here: reset_workspace restores those for every hero at each level. The units digit is set one below 0 because draw_status_panel draws the score by adding a point.
|
|||||||
| 0ECF | .reset_hero←2← 0E09 JSR← 0E74 JSR | ||||||
| LDA hero_start_max_missiles,x ; Starting missile limit... | |||||||
| 0ED2 | STA hero_max_missiles,x ; ...as hero X's missile limit | ||||||
| 0ED5 | LDA hero_start_missile_damage,x ; Starting missile damage... | ||||||
| 0ED8 | STA hero_missile_damage,x ; ...as their missile damage | ||||||
| 0EDB | LDA hero_start_damage_taken,x ; Starting health lost per hit (armour)... | ||||||
| 0EDE | STA hero_damage_taken,x ; ...as their health lost per hit | ||||||
| 0EE1 | LDA #spr_digit_0 ; Score 0000: digit sprite 0... | ||||||
| 0EE3 | STA hero_score_thousands,x ; ...as the thousands digit... | ||||||
| 0EE6 | STA hero_score_hundreds,x ; ...the hundreds digit... | ||||||
| 0EE9 | STA hero_score_tens,x ; ...and the tens digit | ||||||
| 0EEC | LDA #spr_digit_0 - 1 ; ...units one below 0: draw_status_panel adds a point | ||||||
| 0EEE | STA hero_score_units,x ; ...as the units digit | ||||||
| 0EF1 | LDA #spr_small_digit_1 - 1 ; No ten-thousands digit (&69, one below small 1) | ||||||
| 0EF3 | STA hero_score_ten_thousands,x ; ...as the ten-thousands digit | ||||||
| 0EF6 | RTS ; Return, X still the hero | ||||||
Draw the status panelDraw each hero's section of the status panel, the column to the right of the views, Ranger at the top to Fighter at the bottom. level_loop calls it once per level, after start_level has drawn the fresh screen and before remove_absent_heroes. The health and score are drawn by the routines play uses to change them: lose_health_point takes a point from the template's health of 99 + 1, so every hero starts every level on 99, and add_point adds one to the score, which a hero just reset has one below 0000. So a hero who survived the last level, and kept their score, gains a point here at every new level. Then, through plot_panel_sprite, which places each sprite relative to the hero's panel row (hero_panel_y): the face and the shield on the section's top row, with the armour rating (10 - health lost per hit) as a small digit on the shield; the missile damage as a small digit; and one missile icon per missile allowed in flight, three rows apart, beside the health. The keys, the boots icon and the ten-thousands digit are drawn elsewhere. panel_hero is the hero being drawn; count holds the icons' end row.
|
||||||||
| 0EF7 | .draw_status_panel←1← 0E5A JSR | |||||||
| LDA #0 ; For each hero's section... | ||||||||
| 0EF9 | STA panel_hero ; ...starting with the Ranger's, at the top | |||||||
| ; Health and score first, drawn by the routines that change them ; in play. | ||||||||
| 0EFC | .draw_panel_hero←1← 0F65 BNE | |||||||
| LDX panel_hero ; X = this hero | ||||||||
| 0EFF | JSR lose_health_point ; Take a point from the template's 99 + 1: draws 99 | |||||||
| 0F02 | JSR add_point ; Add a point: draws the score (0000 if just reset) | |||||||
| ; The section's top row: the hero's face and the shield, with ; the armour rating on the shield. | ||||||||
| 0F05 | LDA hero_faces,x ; The hero's face (their facing-down sprite)... | |||||||
| 0F08 | LDX #panel_left ; ...at column &45, the panel's left... | |||||||
| 0F0A | LDY #0 ; ...on the section's top row... | |||||||
| 0F0C | JSR plot_panel_sprite ; ...plotted at the section's top left | |||||||
| 0F0F | LDX #panel_left + 8 ; Shield at column &4D, the section's top right | |||||||
| 0F11 | LDY #0 ; ...on the top row... | |||||||
| 0F13 | LDA #spr_shield ; ...the shield sprite... | |||||||
| 0F15 | JSR plot_panel_sprite ; ...plotted, for the armour rating to go on | |||||||
| 0F18 | LDX panel_hero ; Armour rating on the shield: 10 - health lost per hit | |||||||
| 0F1B | SEC ; ...(no borrow into the subtract) | |||||||
| 0F1C | LDA #spr_small_digit_1 + 9 ; ...from &73, small digit 1 + 9... | |||||||
| 0F1E | SBC hero_damage_taken,x ; ...less the damage per hit | |||||||
| 0F21 | LDX #panel_left + 9 ; ...at column &4E... | |||||||
| 0F23 | LDY #2 ; ...2 rows down the section... | |||||||
| 0F25 | JSR plot_panel_sprite ; ...plotted on the shield | |||||||
| ; One missile icon per missile the hero may have in flight, ; three rows apart from row &10. | ||||||||
| 0F28 | LDX panel_hero ; Icon rows run from &10 to &10 + 3 x missile limit... | |||||||
| 0F2B | LDA hero_max_missiles,x ; ...the hero's missile limit, 1-3 at the start... | |||||||
| 0F2E | ASL ; ...x 2... | |||||||
| 0F2F | CLC ; ...(carry clear for the add) | |||||||
| 0F30 | ADC hero_max_missiles,x ; ...+ limit: 3 rows per icon... | |||||||
| 0F33 | ADC #&10 ; ...+ &10: the row after the last icon | |||||||
| 0F35 | STA count ; ...(end row in count) | |||||||
| 0F38 | LDY #&10 ; ...first icon at row &10, beside the health | |||||||
| 0F3A | .draw_missile_icons←1← 0F4B BCC | |||||||
| TYA ; Keep the row... | ||||||||
| 0F3B | PHA ; ...on the stack | |||||||
| 0F3C | LDX #panel_left + 6 ; ...at column &4B | |||||||
| 0F3E | LDA #spr_missile_icon ; ...the missile icon... | |||||||
| 0F40 | JSR plot_panel_sprite ; ...plotted at row Y | |||||||
| 0F43 | PLA ; Recover the row... | |||||||
| 0F44 | CLC ; ...(carry clear for the add) | |||||||
| 0F45 | ADC #3 ; ...3 rows down... | |||||||
| 0F47 | TAY ; ...for the next icon | |||||||
| 0F48 | CPY count ; Past the last icon's row? | |||||||
| 0F4B | BCC draw_missile_icons ; No: plot another | |||||||
| ; The damage the hero's missiles do, then on to the next hero's ; section. | ||||||||
| 0F4D | LDX panel_hero ; Missile damage as a small digit, above the icons | |||||||
| 0F50 | LDA hero_missile_damage,x ; ...the hero's missile damage... | |||||||
| 0F53 | CLC ; ...(carry clear for the add) | |||||||
| 0F54 | ADC #spr_small_digit_1 - 1 ; ...+ &69: small digit 1 for damage 1 | |||||||
| 0F56 | LDX #panel_left + 7 ; ...at column &4C... | |||||||
| 0F58 | LDY #&0a ; ...&0A rows down, four above the health... | |||||||
| 0F5A | JSR plot_panel_sprite ; ...plotted: the damage each missile does | |||||||
| 0F5D | INC panel_hero ; Next hero's section | |||||||
| 0F60 | LDA panel_hero ; All four heroes drawn? | |||||||
| 0F63 | CMP #4 ; ...(four of them) | |||||||
| 0F65 | BNE draw_panel_hero ; No: the next hero | |||||||
| 0F67 | RTS ; Return: all four sections drawn | |||||||
Plot a sprite in a hero's panel sectionPlot sprite A at byte column X and pixel row Y + hero_panel_y - 14 for the hero panel_hero, the one draw_status_panel is drawing. Row 0 of a section is thus 14 rows above the health digits, which sit at the panel row itself. The panel row is read from workspace_template, whose copy in page &0D, made by reset_workspace, is hero_panel_y.
|
|||||||||||||||||
| 0F68 | .plot_panel_sprite←5← 0F0C JSR← 0F15 JSR← 0F25 JSR← 0F40 JSR← 0F5A JSR | ||||||||||||||||
| STX plot_x ; Byte column from X | |||||||||||||||||
| 0F6A | STA sprite_number ; Sprite from A | ||||||||||||||||
| 0F6C | TYA ; Row = Y + this hero's panel row - 14... | ||||||||||||||||
| 0F6D | LDX panel_hero ; ...for the hero being drawn... | ||||||||||||||||
| 0F70 | CLC ; ...(carry clear for the add) | ||||||||||||||||
| 0F71 | ADC workspace_template + 208,x ; ...(read from workspace_template, which page &0D copies) | ||||||||||||||||
| 0F74 | SEC ; ...(no borrow into the subtract) | ||||||||||||||||
| 0F75 | SBC #&0e ; ...less 14: row 0 is 14 above the health | ||||||||||||||||
| 0F77 | STA plot_y ; ...is the plot row | ||||||||||||||||
| 0F79 | JSR plot_sprite ; Plot the sprite in the hero's section | ||||||||||||||||
| 0F7C | RTS ; Return; plot_sprite leaves X and Y 0 | ||||||||||||||||
| 0F7D | EQUB &00, &09, &60 ; Not referenced | ||||||||||||||||
Heroes' starting attributesFour tables of one byte per hero (Ranger, Magic-User, Barbarian, Fighter): missiles in flight, missile damage, health lost per hit, and the face sprite for the panel. |
|
| ; Starting hero_max_missiles for each hero: 3, 2, 1, 2. | |
| 0F80 | .hero_start_max_missiles←1Used as index base by← 0ECF LDA |
| EQUB &03, &02, &01, &02 | |
| ; Starting hero_missile_damage for each hero: 2, 3, 9, 5. | |
| 0F84 | .hero_start_missile_damage←1Used as index base by← 0ED5 LDA |
| EQUB &02, &03, &09, &05 | |
| ; Starting hero_damage_taken for each hero: 7, 9, 6, 4 (armour ; ratings 3, 1, 4, 6). | |
| 0F88 | .hero_start_damage_taken←1Used as index base by← 0EDB LDA |
| EQUB &07, &09, &06, &04 | |
| ; Sprite shown for each hero at the top left of their status ; panel section, plotted by draw_status_panel: &05, &31, &39, ; &41. | |
| 0F8C | .hero_faces←1Used as index base by← 0F05 LDA |
| EQUB &05, &31, &39, &41 | |
Game-over messageEleven lines of seventeen characters, each ended by a carriage return, then a line feed and a last line ended by a zero byte. Two bytes of it (&0FF1, &0FF2) double as counters, and are overwritten with spaces before printing, so the full stop after "YOU ALL" never appears. |
|
| ; The message printed when every hero has died, terminated by a ; zero byte. | |
| 0F90 | .game_over_message←1Used as index base by← 0EAE LDA |
| EQUS "FAREWELL! ", &0D | |
| 0FA2 | EQUS "THE QUEST HAS ", &0D |
| 0FB4 | EQUS "FAILED AND THE ", &0D |
| 0FC6 | EQUS "GODS ARE IN NO ", &0D |
| 0FD8 | EQUS "MOOD TO RESURRECT", &0D |
| ; The "YOU ALL." line of game_over_message, whose bytes after ; the text double as panel_hero and count. | |
| ; Hero counter for draw_status_panel. It is the full stop of ; game_over_message's "YOU ALL.", which is overwritten with a ; space before the message is printed. | |
| ; Counter, used for the dead heroes at the end of a level and ; the rows of missile icons. It is a byte of game_over_message. | |
| 0FEA | .game_over_you_all |
| EQUS "YOU ALL. ", &0D | |
| 0FFC | EQUS "NEW ADVENTURERS ", &0D |
| 100E | EQUS "MUST TAKE YOUR ", &0D |
| 1020 | EQUS "PLACE,BEGINNING ", &0D |
| 1032 | EQUS "BACK ON THE UPPER", &0D |
| 1044 | EQUS "MOST LEVEL. ", &0D |
| 1056 | EQUB &0A ; Line feed: a blank line |
| 1057 | EQUS "FIND THE CHALICE!", &00 |
UnusedLeftover bytes: "ND!" and a zero, the end of an earlier message, then "&C2". |
|
| 1069 | EQUB &4E, &44, &21, &00, &26, &43, &32 ; Not referenced |
Check whether the Chalice has been foundEnd the game in victory when a hero reaches the Chalice. Called by play_level first in every frame, before update_game. On levels other than 25 return at once. On level 25, test each hero's hero_door_x, hero_door_y, the cell move_heroes recorded as the one they last stepped or tried to step into (kept even when a wall stops them, so walking into the Chalice is enough). If it is one of the Chalice's four cells, x &1A-&1B and y 4-5, the game is won: play victory_sequence, set a text window over the views (columns 0-16, rows 0-24, leaving the status panel), clear it, print the ending text, flush the keyboard buffer, wait for a key and call the MOS's reset code through the RESET vector, so this never returns. The ending text is not part of the program: it is the 140 bytes at room_walls + &3A followed by the zero-terminated string at object_free_map + &3A, which on level 25 hold text instead of map data. Both lie clear of &0C00-&0C07, the definition of character 128 that wrch_handler rewrites for every letter or digit it prints. The Chalice's cells are fixed here, not read from the level's objects.
|
||||||||
| 1070 | .check_for_victory←1← 1F0A JSR | |||||||
| LDA level_number ; Which level is this? | ||||||||
| 1073 | CMP #last_level ; The Chalice lies only on level 25 | |||||||
| 1075 | BNE no_victory ; Another level: no Chalice to find | |||||||
| 1077 | LDX #0 ; Has a hero reached a Chalice cell, x &1A-&1B, y 4-5? | |||||||
| 1079 | .check_door_x←1← 1087 BNE | |||||||
| LDA hero_door_x,x ; The cell hero X last stepped or bumped into... | ||||||||
| 107C | CMP #chalice_x ; ...in the Chalice's left column? | |||||||
| 107E | BEQ check_door_y ; Yes: check the row | |||||||
| 1080 | CMP #chalice_x + 1 ; ...or its right column? | |||||||
| 1082 | BEQ check_door_y ; Yes: check the row | |||||||
| 1084 | .next_hero_victory←1← 1095 BNE | |||||||
| INX ; Not at the Chalice: on to the next hero | ||||||||
| 1085 | CPX #4 ; Past hero 3? | |||||||
| 1087 | BNE check_door_x ; No: check the next hero | |||||||
| 1089 | .no_victory←1← 1075 BNE | |||||||
| RTS ; No hero at the Chalice: on with the frame | ||||||||
| 108A | .check_door_y←2← 107E BEQ← 1082 BEQ | |||||||
| LDA hero_door_y,x ; ...and that cell's row... | ||||||||
| 108D | CMP #chalice_y ; ...in the Chalice's top row? | |||||||
| 108F | BEQ start_victory ; Yes: the Chalice is found | |||||||
| 1091 | CMP #chalice_y + 1 ; ...or its bottom row? | |||||||
| 1093 | BEQ start_victory ; Yes: the Chalice is found | |||||||
| 1095 | BNE next_hero_victory ; No: next hero | |||||||
| 1097 | .start_victory←2← 108F BEQ← 1093 BEQ | |||||||
| JSR victory_sequence ; Sparkles, rising tone, the Chalice dissolves | ||||||||
| ; The game is won. Over the views, print the ending text that ; level 25's maps hold, wait for a key, and reset. | ||||||||
| 109A | LDA #&1c ; VDU 28,0,24,16,0: a window over the four views... | |||||||
| 109C | JSR oswrch ; Send VDU 28 | |||||||
| 109F | LDA #0 ; Left column 0 | |||||||
| 10A1 | JSR oswrch ; Send the left column | |||||||
| 10A4 | LDA #&18 ; Bottom row 24, the last on show | |||||||
| 10A6 | JSR oswrch ; Send the bottom row | |||||||
| 10A9 | LDA #&10 ; Right column 16: the status panel stays | |||||||
| 10AB | JSR oswrch ; Send the right column | |||||||
| 10AE | LDA #0 ; Top row 0 | |||||||
| 10B0 | JSR oswrch ; Send the top row | |||||||
| 10B3 | LDA #&0c ; ...VDU 12 to clear it | |||||||
| 10B5 | JSR oswrch ; Clear the views for the ending text | |||||||
| ; Print the ending text: 140 bytes of level 25's wall map, then ; its object-free map up to a zero. | ||||||||
| 10B8 | LDX #0 ; The ending text: 140 bytes from room_walls + &3A... | |||||||
| 10BA | .print_victory_text←1← 10C3 BNE | |||||||
| LDA room_walls + 58,x ; Next byte of level 25's wall map, which is text | ||||||||
| 10BD | JSR osasci ; Print it in the game's font | |||||||
| 10C0 | INX ; On through the 140 bytes | |||||||
| 10C1 | CPX #&8c ; All 140 printed? | |||||||
| 10C3 | BNE print_victory_text ; No: print the next | |||||||
| 10C5 | LDX #0 ; ...then the ending message, at object_free_map + &3A | |||||||
| 10C7 | .print_ending_message←1← 10D0 BNE | |||||||
| LDA object_free_map + 58,x ; Next character of the ending message | ||||||||
| 10CA | JSR osasci ; Print it, the zero included | |||||||
| 10CD | INX ; On along the message (X stays non-zero) | |||||||
| 10CE | CMP #0 ; The zero that ends the message? | |||||||
| 10D0 | BNE print_ending_message ; No: print the next | |||||||
| ; Wait for a fresh key press, then reset the machine through the ; RESET vector. | ||||||||
| 10D2 | LDA #osbyte_flush_buffer_class ; OSBYTE &0F, X non-zero: flush the input buffer... | |||||||
| 10D4 | JSR osbyte ; ...so keys pressed in the sequence cannot skip the text Flush selected class of buffer | |||||||
| 10D7 | JSR osrdch ; Wait for a key once the ending text has been read | |||||||
| 10DA | LDA reset_vector ; Aim the JSR below at the MOS's reset code... | |||||||
| 10DD | STA reset_call_address ; ...the RESET vector's low byte as its operand's... | |||||||
| 10E0 | LDA reset_vector + 1 ; ...and the vector's high byte... | |||||||
| 10E3 | STA reset_call_address + 1 ; ...as its high: no MOS address built in | |||||||
| ; Operand of the JSR at reset_call, set from the RESET vector. | ||||||||
| 10E6 | .reset_call | |||||||
| JSR &00 ; ...and call it: the game ends with a reset | ||||||||
| fall through ↓ | ||||||||
Play the victory sequenceSparkles circle the Chalice to a rising, quickening bell tone, and the Chalice dissolves into black. Called by check_for_victory once a hero reaches the Chalice; play is frozen meanwhile, as nothing else runs. Each pass sounds the bell, draws the ring of sparkles round the Chalice (draw_victory_ring), and waits. The bell's pitch climbs by a step each pass and wraps past 255, and each time it wraps the step grows by 1, so the tone repeats as ever faster sweeps: about 256 x (1 + 1/2 + ... + 1/50), some 1,150 passes in all. The wait starts at &E6 units of about 1,280 cycles each and shortens by one a pass down to 1, reached on pass 229, near the end of the first sweep; from then on each pass also calls dissolve_chalice, which clears a random byte of the Chalice when its random value is below &C0. After the 50th wrap (erase_victory_ring), erase the ring, clear whatever is left of the Chalice's sprite, replot it black, and wait 255 vertical syncs, about five seconds. The Chalice's sprite data stays cleared, as the game resets next. OSBYTEs &D4 and &D5 set (old AND Y) EOR X, and Y is never set for them: the bell's envelope byte takes Y left over from the frame, and the first pitch takes the Y that OSBYTE &D4 returns; later passes have Y = 0 from the wait loop, so the pitch is exactly victory_pitch.
|
||||||||
| 10E9 | .victory_sequence←1← 1097 JSR | |||||||
| LDA #osbyte_bell_envelope ; OSBYTE &D4: the bell's envelope byte... | ||||||||
| 10EB | LDX #8 ; ...EOR 8; Y, not set, is the AND mask | |||||||
| 10ED | JSR osbyte ; Set the bell's envelope for the victory tone osbyte: bell envelope | |||||||
| ; Set up the sequence: no pixel offsets, the first sparkle, ; pitch 0 rising by 1, a wait of &E6, 50 sweeps. | ||||||||
| 10F0 | LDA #0 ; Plot the ring and Chalice square on their cells: | |||||||
| 10F2 | STA plot_offset_x ; ...no x offset... | |||||||
| 10F4 | STA plot_offset_y ; ...and no y offset | |||||||
| 10F6 | LDA #spr_sparkle_0 ; The ring starts with the first sparkle | |||||||
| 10F8 | STA victory_sprite ; ...as the ring's sprite | |||||||
| 10FA | LDA #0 ; Tone starts at pitch 0... | |||||||
| 10FC | STA victory_pitch ; ...for the bell | |||||||
| 10FE | LDA #&e6 ; ...with the passes &E6 wait units apart... | |||||||
| 1100 | STA victory_delay ; ...the delay loop's outer count | |||||||
| 1102 | LDA #&32 ; ...for &32 (50) sweeps of the pitch... | |||||||
| 1104 | STA victory_steps_left ; ...counted down as the pitch wraps | |||||||
| 1106 | LDA #1 ; ...rising by 1 a pass in the first sweep | |||||||
| 1108 | STA victory_pitch_step ; ...the pitch's first step | |||||||
| ; One pass of the sequence: raise the pitch, shorten the wait, ; sound the bell, draw the ring, dissolve a byte of the Chalice ; once at full speed, and wait. | ||||||||
| 110A | .raise_victory_pitch←1← 1146 JMP | |||||||
| CLC ; Pitch = (pitch + step) mod 256, C set on a wrap... | ||||||||
| 110B | LDA victory_pitch ; ...the bell's current pitch... | |||||||
| 110D | ADC victory_pitch_step ; ...plus this sweep's step... | |||||||
| 110F | STA victory_pitch ; ...stored as the pitch for this pass | |||||||
| 1111 | BCC shorten_victory_delay ; No wrap: the sweep goes on | |||||||
| 1113 | INC victory_pitch_step ; Wrapped: the next sweep climbs one step faster... | |||||||
| 1115 | DEC victory_steps_left ; ...and one fewer sweep is left | |||||||
| 1117 | BNE shorten_victory_delay ; Sweeps left: go on | |||||||
| 1119 | JMP erase_victory_ring ; 50 sweeps done: erase the ring and the Chalice | |||||||
| 111C | .shorten_victory_delay←2← 1111 BCC← 1117 BNE | |||||||
| DEC victory_delay ; Shorten the wait: the passes come faster... | ||||||||
| 111E | BNE sound_victory_bell ; Not yet zero: keep it | |||||||
| 1120 | LDA #1 ; ...but never below 1... | |||||||
| 1122 | STA victory_delay ; ...the full speed the rest of the sequence runs at | |||||||
| 1124 | .sound_victory_bell←1← 111E BNE | |||||||
| LDX victory_pitch ; OSBYTE &D5: the bell's pitch... | ||||||||
| 1126 | LDA #osbyte_bell_frequency ; ...set it from victory_pitch | |||||||
| 1128 | JSR osbyte ; Set it: the bell now sounds at that pitch osbyte: bell frequency | |||||||
| 112B | LDA #7 ; ...and sound the bell | |||||||
| 112D | JSR oswrch ; Send BEL: the bell sounds at the new pitch | |||||||
| 1130 | JSR draw_victory_ring ; Draw the ring, the sparkles one side further round | |||||||
| 1133 | LDA victory_delay ; At full speed, dissolve the Chalice a byte at a time | |||||||
| 1135 | CMP #1 ; Delay down to 1: the sequence is at full speed | |||||||
| 1137 | BNE victory_delay_loop ; Not yet: just wait | |||||||
| 1139 | JSR dissolve_chalice ; Full speed: clear one more byte of the Chalice | |||||||
| 113C | .victory_delay_loop←1← 1137 BNE | |||||||
| LDX victory_delay ; Wait victory_delay units before the next pass | ||||||||
| 113E | .victory_delay_outer←1← 1144 BNE | |||||||
| LDY #&ff ; Each unit is 255 inner loops, about 1,280 cycles | ||||||||
| 1140 | .victory_delay_inner←1← 1141 BNE | |||||||
| DEY ; Count down the inner loop | ||||||||
| 1141 | BNE victory_delay_inner ; Until it reaches zero | |||||||
| 1143 | DEX ; Count down the delay units | |||||||
| 1144 | BNE victory_delay_outer ; Until the delay is spent (Y = 0 for the next OSBYTE) | |||||||
| 1146 | JMP raise_victory_pitch ; Next pass: raise the pitch again | |||||||
Draw the ring of sprites round the ChaliceDraw one frame of the sparkling ring. Called by victory_sequence once a pass, and once more with the blank sprite to erase the ring. Plot victory_sprite at the twelve cells round the Chalice's 2 x 2 block (x &19-&1C, y 3-6, all in the Chalice's room), from x &1C, y 3 leftwards along the top, down the left side, along the bottom and up the right side, three cells to a side, each corner starting a side. The sprite moves on to the next sparkle (next_victory_sprite) after each of the first three sides and is left at the fourth side's, so the next ring starts with it and the sparkles move one side round the ring each pass. With the blank sprite, it erases the ring.
|
|||||||||||||
| 1149 | .draw_victory_ring←2← 1130 JSR← 11D7 JSR | ||||||||||||
| LDA #chalice_x + 2 ; Start at x &1C, y 3: the ring runs round the Chalice's four cells | |||||||||||||
| 114B | STA ring_x ; ...as the ring's x... | ||||||||||||
| 114D | LDA #chalice_y - 1 ; ...one row above the Chalice... | ||||||||||||
| 114F | STA ring_y ; ...as the ring's y | ||||||||||||
| 1151 | JSR plot_victory_sprite ; Plot the top-right corner, first of the top side | ||||||||||||
| 1154 | DEC ring_x ; Left to x &1B, above the Chalice's right column | ||||||||||||
| 1156 | JSR plot_victory_sprite ; Plot the top side's second cell | ||||||||||||
| 1159 | DEC ring_x ; Left to x &1A, above its left column | ||||||||||||
| 115B | JSR plot_victory_sprite ; Plot the last of the top side's three | ||||||||||||
| 115E | LDA victory_sprite ; Keep the sprite... | ||||||||||||
| 1160 | STA victory_sprite_copy ; ...in victory_sprite_copy, which nothing reads | ||||||||||||
| 1163 | JSR next_victory_sprite ; ...and move to the next sparkle for the left side | ||||||||||||
| 1166 | DEC ring_x ; Left to x &19: the top-left corner | ||||||||||||
| 1168 | JSR plot_victory_sprite ; Plot it, first of the left side | ||||||||||||
| 116B | INC ring_y ; Down to y 4, beside the Chalice's top row | ||||||||||||
| 116D | JSR plot_victory_sprite ; Plot the left side's second cell | ||||||||||||
| 1170 | INC ring_y ; Down to y 5, beside its bottom row | ||||||||||||
| 1172 | JSR plot_victory_sprite ; Plot the left side's third cell | ||||||||||||
| 1175 | JSR next_victory_sprite ; Next sparkle for the bottom side | ||||||||||||
| 1178 | INC ring_y ; Down to y 6: the bottom-left corner | ||||||||||||
| 117A | JSR plot_victory_sprite ; Plot it, first of the bottom side | ||||||||||||
| 117D | INC ring_x ; Right to x &1A, below the Chalice's left column | ||||||||||||
| 117F | JSR plot_victory_sprite ; Plot the bottom side's second cell | ||||||||||||
| 1182 | INC ring_x ; Right to x &1B, below its right column | ||||||||||||
| 1184 | JSR plot_victory_sprite ; Plot the bottom side's third cell | ||||||||||||
| 1187 | JSR next_victory_sprite ; Next sparkle for the right side, kept for the next ring | ||||||||||||
| 118A | INC ring_x ; Right to x &1C: the bottom-right corner | ||||||||||||
| 118C | JSR plot_victory_sprite ; Plot it, first of the right side | ||||||||||||
| 118F | DEC ring_y ; Up to y 5, beside the Chalice's bottom row | ||||||||||||
| 1191 | JSR plot_victory_sprite ; Plot the right side's second cell | ||||||||||||
| 1194 | DEC ring_y ; Up to y 4, beside its top row | ||||||||||||
| 1196 | JSR plot_victory_sprite ; Plot the right side's third, closing the ring | ||||||||||||
| 1199 | RTS ; Return, victory_sprite at the right side's sparkle | ||||||||||||
Plot a victory sprite at a cellPlot victory_sprite at the cell ring_x, ring_y in every view showing it, with the pixel offsets victory_sequence cleared. Called by draw_victory_ring for each of the ring's twelve cells; ring_x and ring_y are left as they were, for the next step.
|
|||||||||||||||
| 119A | .plot_victory_sprite←12← 1151 JSR← 1156 JSR← 115B JSR← 1168 JSR← 116D JSR← 1172 JSR← 117A JSR← 117F JSR← 1184 JSR← 118C JSR← 1191 JSR← 1196 JSR | ||||||||||||||
| LDA ring_x ; Plot the victory sprite at the ring cell | |||||||||||||||
| 119C | STA cell_x ; ...as the cell's x | ||||||||||||||
| 119F | LDA ring_y ; ...and its y... | ||||||||||||||
| 11A1 | STA cell_y ; ...as the cell's y | ||||||||||||||
| 11A4 | LDA victory_sprite ; ...with the ring's current sprite... | ||||||||||||||
| 11A6 | STA sprite_number ; ...as the sprite to plot | ||||||||||||||
| 11A8 | JSR plot_at_cell ; ...in every view that shows the cell | ||||||||||||||
| 11AB | RTS ; Return to draw_victory_ring for the next cell | ||||||||||||||
Choose the next victory spriteStep victory_sprite through the four sparkles, &16-&19, wrapping back to &16. Called by draw_victory_ring between the ring's sides, so each side shows a different sparkle. The blank sprite, &15, used to erase the ring, is left alone, so an erasing ring stays blank all the way round.
|
|||||||||||||
| 11AC | .next_victory_sprite←3← 1163 JSR← 1175 JSR← 1187 JSR | ||||||||||||
| LDA victory_sprite ; Erasing (sprite &15)? Keep it | |||||||||||||
| 11AE | CMP #spr_blank ; ...the blank sprite? | ||||||||||||
| 11B0 | BEQ store_victory_sprite ; Yes: keep erasing | ||||||||||||
| 11B2 | CLC ; Next sparkle, &16-&19 in turn | ||||||||||||
| 11B3 | ADC #1 ; ...the next sparkle sprite | ||||||||||||
| 11B5 | CMP #spr_sparkle_3 + 1 ; Past the last sparkle? | ||||||||||||
| 11B7 | BNE store_victory_sprite ; No: use it | ||||||||||||
| 11B9 | LDA #spr_sparkle_0 ; Yes: back to the first sparkle | ||||||||||||
| 11BB | .store_victory_sprite←2← 11B0 BEQ← 11B7 BNE | ||||||||||||
| STA victory_sprite ; Make it the ring's sprite | |||||||||||||
| 11BD | RTS ; Return with A = victory_sprite | ||||||||||||
Clear a random byte of the ChaliceEat one more hole in the Chalice. Called by victory_sequence on every pass once its wait is down to 1. Make a random number from the System VIA's timer 1 low byte mixed with two bytes of MOS workspace (&FC and &FA). If it is below &C0, the size of the Chalice's 8 x 24-byte sprite, zero that byte of sprite_chalice and replot the Chalice, so it dissolves into black a pixel pair at a time; otherwise do nothing this pass. A byte already clear may be chosen again, so some survive until erase_victory_ring clears the rest.
|
||||||||
| 11BE | .dissolve_chalice←1← 1139 JSR | |||||||
| LDA system_via_t1c_l ; Pick a byte of the Chalice: System VIA timer 1... | ||||||||
| 11C1 | EOR os_irq_a ; ...mixed with the MOS's last interrupt A... | |||||||
| 11C3 | EOR os_zp_fa ; ...and more MOS workspace, for randomness | |||||||
| 11C5 | CMP #&c0 ; Within the Chalice's &C0 bytes? | |||||||
| 11C7 | BCS dissolve_done ; No: nothing dissolves this pass | |||||||
| 11C9 | TAX ; X = the chosen byte's offset in the sprite... | |||||||
| 11CA | LDA #0 ; ...cleared to zero, a black pair of pixels... | |||||||
| 11CC | STA sprite_chalice,x ; ...in the Chalice's sprite data | |||||||
| 11CF | JSR plot_chalice ; ...and replot the Chalice with the hole in it | |||||||
| 11D2 | .dissolve_done←1← 11C7 BCS | |||||||
| RTS ; Return to victory_sequence's wait | ||||||||
| ; The 50th sweep is done: erase the ring, clear the rest of the ; Chalice, and hold the scene for 255 vsyncs. | ||||||||
| 11D3 | .erase_victory_ring←1← 1119 JMP | |||||||
| LDA #spr_blank ; Erase the ring | ||||||||
| 11D5 | STA victory_sprite ; ...by making the blank the ring's sprite... | |||||||
| 11D7 | JSR draw_victory_ring ; ...and drawing the ring with it | |||||||
| 11DA | LDX #&c1 ; Clear what is left of the Chalice... | |||||||
| 11DC | LDA #0 ; ...to zeros, black pixels | |||||||
| 11DE | .clear_chalice_sprite←1← 11E2 BNE | |||||||
| STA sprite_chalice - 1,x ; Clear a byte of the Chalice's sprite data | ||||||||
| 11E1 | DEX ; Next byte down | |||||||
| 11E2 | BNE clear_chalice_sprite ; &C1 bytes: the &C0 and the unused byte after | |||||||
| 11E4 | JSR plot_chalice ; ...and replot it, now black: the Chalice is gone | |||||||
| 11E7 | LDA #&ff ; Pause 255 vertical syncs (about five seconds) | |||||||
| 11E9 | STA os_vsync_counter ; ...which the MOS counts down at each vsync | |||||||
| 11EC | .wait_vsync_chalice←1← 11EF BNE | |||||||
| LDA os_vsync_counter ; Read the count | ||||||||
| 11EF | BNE wait_vsync_chalice ; Until it reaches zero | |||||||
| 11F1 | RTS ; Return to check_for_victory for the ending text | |||||||
Plot the ChalicePlot sprite &73, the Chalice, at its top-left cell (x &1A, y 4) in every view showing it, as its sprite data now stands. Called by dissolve_chalice after each byte it clears, and at the end of victory_sequence to show it gone. The sprite is two cells wide and two high, so it covers the four cells check_for_victory tests. The pixel offsets are those victory_sequence cleared.
|
||||||||
| 11F2 | .plot_chalice←2← 11CF JSR← 11E4 JSR | |||||||
| LDA #chalice_x ; The Chalice's top-left cell, x &1A, y 4... | ||||||||
| 11F4 | STA cell_x ; ...as the cell's x | |||||||
| 11F7 | LDA #chalice_y ; ...and y 4... | |||||||
| 11F9 | STA cell_y ; ...as the cell's y | |||||||
| 11FC | LDA #spr_chalice ; ...sprite &73, 2 x 2 cells... | |||||||
| 11FE | STA sprite_number ; ...as the sprite to plot... | |||||||
| 1200 | JSR plot_at_cell ; ...plotted in every view showing it | |||||||
| 1203 | RTS ; Return with the Chalice drawn as its data stands | |||||||
UnusedLeftover bytes, never read: &52 &78 &60 repeat the end of plot_chalice (JSR plot_at_cell's operand, then RTS), and the rest reads as a fragment of BASIC text, "(&1900+F". |
|
| 1204 | EQUS "Rx`(&1900+F%" |
The Chalice spriteSprite &73: 8 bytes by 24 rows, two cells by two, plotted at x &1A, y 4 by plot_chalice. In the victory sequence dissolve_chalice zeros random bytes of it and erase_victory_ring zeros all of it (and the byte after); the game then ends in a reset. |
|
| ; Data of sprite &73: 8 bytes x 24 rows. | |
| 1210 | .sprite_chalice←1Used as index base by← 11CC STA |
| EQUB &00, &00, &05, &0F, &0F, &0A, &00, &00, &00, &00, &0F, &07, &0B, &0F, &00, &00, &00, &05, &0B, &03, &03, &07, &0A, &00, &00, &0F, &07, &5A, &A5, &0B, &0F, &00, &00, &0F, &07, &0F, &0F, &0B, &0F, &00, &05, &0B, &0F, &00, &00, &0F, &07, &0A, &05, &0B, &0A, &00, &00, &05, &07, &0A, &0F, &07, &0E, &00, &00, &0D, &0B, &0F, &0F, &07, &04, &08, &04, &08, &0B, &0F, &0B, &07, &45, &0C, &0C, &8A, &0B, &07, &0F, &07, &00, &0C, &0C, &00, &0B, &0F, &5A, &07, &0C, &4D, &8E, &0C, &0B, &A5, &5A, &07, &0C, &4D, &8E, &0C, &0B, &A5, &0F, &07, &00, &0C, &0C, &00, &0B, &0F, &0B, &07, &45, &0C, &0C, &8A, &0B, &07, &0F, &07, &04, &08, &04, &08, &0B, &0F, &0F, &07, &0E, &00, &00, &0D, &0B, &0F, &05, &0B, &0A, &00, &00, &05, &07, &0A, &05, &0B, &0F, &00, &00, &0F, &07, &0A, &00, &0F, &07, &0F, &0F, &0B, &0F, &00, &00, &0F, &07, &5A, &A5, &0B, &0F, &00, &00, &05, &0B, &03, &03, &07, &0A, &00, &00, &00, &0F, &07, &0B, &0F, &00, &00, &00, &00, &05, &0F, &0F, &0A, &00, &00 | |
| 12D0 | EQUB &3D ; Written only by erase_victory_ring, whose clear of sprite_chalice runs one byte past its end |
| 12D1 | EQUB &26, &00 ; Not referenced |
| ; The WRCHV contents found at start-up, restored while the game ; uses the MOS's own text output. | |
| 12D3 | .saved_wrchv←2← 0D58 STA← 14D7 LDA |
| EQUB &A4 ; WRCHV as saved at start-up, low byte (&A4 as loaded) | |
| 12D4 | EQUB &E0 ; ...and high byte (&E0 as loaded) |
| 12D5 | EQUB &00, &73 ; Not referenced |
Font: letters A-ZEight bytes per letter, copied into the definition of character 128 by the WRCHV handler. |
|
| ; The game's font for the letters A-Z: eight bytes per letter, ; one per pixel row, in MOS character-definition format. | |
| 12D7 | .font_letters←1Used as index base by← 7FC5 LDA |
| EQUB %00111100 ; 'A' | |
| 12D8 | EQUB %01000010 |
| 12D9 | EQUB %01000010 |
| 12DA | EQUB %10001110 |
| 12DB | EQUB %11110010 |
| 12DC | EQUB %10000010 |
| 12DD | EQUB %11000110 |
| 12DE | EQUB %00000000 |
| 12DF | EQUB %01111000 ; 'B' |
| 12E0 | EQUB %01000100 |
| 12E1 | EQUB %01000010 |
| 12E2 | EQUB %10111100 |
| 12E3 | EQUB %10000010 |
| 12E4 | EQUB %10000010 |
| 12E5 | EQUB %11111100 |
| 12E6 | EQUB %00000000 |
| 12E7 | EQUB %00111100 ; 'C' |
| 12E8 | EQUB %01000010 |
| 12E9 | EQUB %01000000 |
| 12EA | EQUB %10000000 |
| 12EB | EQUB %10000000 |
| 12EC | EQUB %10000010 |
| 12ED | EQUB %01111100 |
| 12EE | EQUB %00000000 |
| 12EF | EQUB %01111100 ; 'D' |
| 12F0 | EQUB %10000010 |
| 12F1 | EQUB %10000010 |
| 12F2 | EQUB %10000010 |
| 12F3 | EQUB %10000100 |
| 12F4 | EQUB %10000100 |
| 12F5 | EQUB %11111000 |
| 12F6 | EQUB %00000000 |
| 12F7 | EQUB %00001110 ; 'E' |
| 12F8 | EQUB %01110000 |
| 12F9 | EQUB %01000000 |
| 12FA | EQUB %11001110 |
| 12FB | EQUB %11110000 |
| 12FC | EQUB %10000000 |
| 12FD | EQUB %11111110 |
| 12FE | EQUB %00000000 |
| 12FF | EQUB %00011110 ; 'F' |
| 1300 | EQUB %11100000 |
| 1301 | EQUB %10000000 |
| 1302 | EQUB %10001110 |
| 1303 | EQUB %11110000 |
| 1304 | EQUB %10000000 |
| 1305 | EQUB %11000000 |
| 1306 | EQUB %00000000 |
| 1307 | EQUB %00111100 ; 'G' |
| 1308 | EQUB %01000010 |
| 1309 | EQUB %01000010 |
| 130A | EQUB %10000000 |
| 130B | EQUB %10011110 |
| 130C | EQUB %10000010 |
| 130D | EQUB %01111110 |
| 130E | EQUB %00000000 |
| 130F | EQUB %01100010 ; 'H' |
| 1310 | EQUB %01000010 |
| 1311 | EQUB %01000010 |
| 1312 | EQUB %10011110 |
| 1313 | EQUB %11100010 |
| 1314 | EQUB %10000010 |
| 1315 | EQUB %11000110 |
| 1316 | EQUB %00000000 |
| 1317 | EQUB %00011110 ; 'I' |
| 1318 | EQUB %00001000 |
| 1319 | EQUB %00001000 |
| 131A | EQUB %00010000 |
| 131B | EQUB %00010000 |
| 131C | EQUB %00010000 |
| 131D | EQUB %01111100 |
| 131E | EQUB %00000000 |
| 131F | EQUB %11111110 ; 'J' |
| 1320 | EQUB %00000010 |
| 1321 | EQUB %00000010 |
| 1322 | EQUB %00000100 |
| 1323 | EQUB %11000100 |
| 1324 | EQUB %10000100 |
| 1325 | EQUB %01111000 |
| 1326 | EQUB %00000000 |
| 1327 | EQUB %01000000 ; 'K' |
| 1328 | EQUB %01001110 |
| 1329 | EQUB %01110000 |
| 132A | EQUB %10001000 |
| 132B | EQUB %10001000 |
| 132C | EQUB %10000100 |
| 132D | EQUB %11000010 |
| 132E | EQUB %00000000 |
| 132F | EQUB %01100000 ; 'L' |
| 1330 | EQUB %01000000 |
| 1331 | EQUB %01000000 |
| 1332 | EQUB %10000000 |
| 1333 | EQUB %10000000 |
| 1334 | EQUB %10000010 |
| 1335 | EQUB %11111110 |
| 1336 | EQUB %00000000 |
| 1337 | EQUB %01000110 ; 'M' |
| 1338 | EQUB %01101110 |
| 1339 | EQUB %01101010 |
| 133A | EQUB %11011010 |
| 133B | EQUB %10010010 |
| 133C | EQUB %10000010 |
| 133D | EQUB %11000110 |
| 133E | EQUB %00000000 |
| 133F | EQUB %01100110 ; 'N' |
| 1340 | EQUB %01010010 |
| 1341 | EQUB %01010010 |
| 1342 | EQUB %10001010 |
| 1343 | EQUB %10001010 |
| 1344 | EQUB %10001010 |
| 1345 | EQUB %11000110 |
| 1346 | EQUB %00000000 |
| 1347 | EQUB %00111100 ; 'O' |
| 1348 | EQUB %01000010 |
| 1349 | EQUB %01000010 |
| 134A | EQUB %10000010 |
| 134B | EQUB %10000010 |
| 134C | EQUB %10000010 |
| 134D | EQUB %01111100 |
| 134E | EQUB %00000000 |
| 134F | EQUB %01111100 ; 'P' |
| 1350 | EQUB %01000010 |
| 1351 | EQUB %01000010 |
| 1352 | EQUB %10111100 |
| 1353 | EQUB %10000000 |
| 1354 | EQUB %10000000 |
| 1355 | EQUB %11000000 |
| 1356 | EQUB %00000000 |
| 1357 | EQUB %00111100 ; 'Q' |
| 1358 | EQUB %01000010 |
| 1359 | EQUB %01000010 |
| 135A | EQUB %10011010 |
| 135B | EQUB %10001010 |
| 135C | EQUB %10000110 |
| 135D | EQUB %01111110 |
| 135E | EQUB %00000000 |
| 135F | EQUB %01111100 ; 'R' |
| 1360 | EQUB %01000010 |
| 1361 | EQUB %01000010 |
| 1362 | EQUB %10111100 |
| 1363 | EQUB %10001000 |
| 1364 | EQUB %10000100 |
| 1365 | EQUB %11000010 |
| 1366 | EQUB %00000000 |
| 1367 | EQUB %00011110 ; 'S' |
| 1368 | EQUB %00100010 |
| 1369 | EQUB %01000000 |
| 136A | EQUB %00111100 |
| 136B | EQUB %00000010 |
| 136C | EQUB %10000010 |
| 136D | EQUB %11111100 |
| 136E | EQUB %00000000 |
| 136F | EQUB %11111110 ; 'T' |
| 1370 | EQUB %10010010 |
| 1371 | EQUB %00010000 |
| 1372 | EQUB %00100000 |
| 1373 | EQUB %00100000 |
| 1374 | EQUB %00100000 |
| 1375 | EQUB %01110000 |
| 1376 | EQUB %00000000 |
| 1377 | EQUB %01100110 ; 'U' |
| 1378 | EQUB %01000010 |
| 1379 | EQUB %01000010 |
| 137A | EQUB %10000010 |
| 137B | EQUB %10000010 |
| 137C | EQUB %10000010 |
| 137D | EQUB %01111100 |
| 137E | EQUB %00000000 |
| 137F | EQUB %11000110 ; 'V' |
| 1380 | EQUB %01000010 |
| 1381 | EQUB %01000010 |
| 1382 | EQUB %10000010 |
| 1383 | EQUB %10000100 |
| 1384 | EQUB %01001000 |
| 1385 | EQUB %00110000 |
| 1386 | EQUB %00000000 |
| 1387 | EQUB %01100110 ; 'W' |
| 1388 | EQUB %01000010 |
| 1389 | EQUB %01000010 |
| 138A | EQUB %10010010 |
| 138B | EQUB %10101010 |
| 138C | EQUB %01001010 |
| 138D | EQUB %01000100 |
| 138E | EQUB %00000000 |
| 138F | EQUB %01100110 ; 'X' |
| 1390 | EQUB %00100010 |
| 1391 | EQUB %00100100 |
| 1392 | EQUB %00011000 |
| 1393 | EQUB %00011000 |
| 1394 | EQUB %00100100 |
| 1395 | EQUB %11000110 |
| 1396 | EQUB %00000000 |
| 1397 | EQUB %10000110 ; 'Y' |
| 1398 | EQUB %01000010 |
| 1399 | EQUB %00110010 |
| 139A | EQUB %00001100 |
| 139B | EQUB %00001000 |
| 139C | EQUB %00010000 |
| 139D | EQUB %01110000 |
| 139E | EQUB %00000000 |
| 139F | EQUB %01111110 ; 'Z' |
| 13A0 | EQUB %00000010 |
| 13A1 | EQUB %00000100 |
| 13A2 | EQUB %00011000 |
| 13A3 | EQUB %00100000 |
| 13A4 | EQUB %01000010 |
| 13A5 | EQUB %11111110 |
| 13A6 | EQUB %00000000 |
Font: digits 0-9Eight bytes per digit, copied into the definition of character 128 by the WRCHV handler. |
|
| ; The game's font for the digits 0-9, in the same format as ; font_letters. | |
| 13A7 | .font_digits←1Used as index base by← 7FE8 LDA |
| EQUB %00111100 ; '0' | |
| 13A8 | EQUB %01000110 |
| 13A9 | EQUB %01001010 |
| 13AA | EQUB %10010010 |
| 13AB | EQUB %10100010 |
| 13AC | EQUB %11000100 |
| 13AD | EQUB %01111000 |
| 13AE | EQUB %00000000 |
| 13AF | EQUB %00001000 ; '1' |
| 13B0 | EQUB %00011000 |
| 13B1 | EQUB %00001000 |
| 13B2 | EQUB %00010000 |
| 13B3 | EQUB %00010000 |
| 13B4 | EQUB %00010000 |
| 13B5 | EQUB %00111100 |
| 13B6 | EQUB %00000000 |
| 13B7 | EQUB %00111100 ; '2' |
| 13B8 | EQUB %01000010 |
| 13B9 | EQUB %00000010 |
| 13BA | EQUB %00001100 |
| 13BB | EQUB %00110000 |
| 13BC | EQUB %01000010 |
| 13BD | EQUB %11111100 |
| 13BE | EQUB %00000000 |
| 13BF | EQUB %01111110 ; '3' |
| 13C0 | EQUB %00000010 |
| 13C1 | EQUB %00000100 |
| 13C2 | EQUB %00011000 |
| 13C3 | EQUB %00000110 |
| 13C4 | EQUB %10000010 |
| 13C5 | EQUB %01111100 |
| 13C6 | EQUB %00000000 |
| 13C7 | EQUB %00011000 ; '4' |
| 13C8 | EQUB %00101000 |
| 13C9 | EQUB %01001000 |
| 13CA | EQUB %10010000 |
| 13CB | EQUB %11111100 |
| 13CC | EQUB %00010000 |
| 13CD | EQUB %00111000 |
| 13CE | EQUB %00000000 |
| 13CF | EQUB %00011111 ; '5' |
| 13D0 | EQUB %00100000 |
| 13D1 | EQUB %00100000 |
| 13D2 | EQUB %00011000 |
| 13D3 | EQUB %00000100 |
| 13D4 | EQUB %10000010 |
| 13D5 | EQUB %01111100 |
| 13D6 | EQUB %00000000 |
| 13D7 | EQUB %00001110 ; '6' |
| 13D8 | EQUB %00010000 |
| 13D9 | EQUB %00100000 |
| 13DA | EQUB %01111100 |
| 13DB | EQUB %10000010 |
| 13DC | EQUB %10000010 |
| 13DD | EQUB %01111100 |
| 13DE | EQUB %00000000 |
| 13DF | EQUB %01111110 ; '7' |
| 13E0 | EQUB %00000010 |
| 13E1 | EQUB %00000010 |
| 13E2 | EQUB %00000100 |
| 13E3 | EQUB %00001000 |
| 13E4 | EQUB %00010000 |
| 13E5 | EQUB %01111000 |
| 13E6 | EQUB %00000000 |
| 13E7 | EQUB %00011100 ; '8' |
| 13E8 | EQUB %00100010 |
| 13E9 | EQUB %00100010 |
| 13EA | EQUB %01111100 |
| 13EB | EQUB %10000010 |
| 13EC | EQUB %10000010 |
| 13ED | EQUB %01111100 |
| 13EE | EQUB %00000000 |
| 13EF | EQUB %00111100 ; '9' |
| 13F0 | EQUB %01000010 |
| 13F1 | EQUB %01000010 |
| 13F2 | EQUB %00111110 |
| 13F3 | EQUB %00000010 |
| 13F4 | EQUB %00000100 |
| 13F5 | EQUB %00011000 |
| 13F6 | EQUB %00000000 |
UnusedLeftover bytes, never read: a second copy of the digit 9's eight glyph rows, then &74. |
|
| 13F7 | EQUS "<BB>" |
| 13FB | EQUB &02, &04, &18, &00, &74 ; Not referenced |
Set up and draw a new levelTurn the next level's file into a fresh play screen. Called from the level loop (&0E57) at the start of every level; the loop then draws the status panel and plays the level. In order: prepare the text area (the first call, which differs between releases), get the level file at &6B00 decrypted and checked, unpack it into the game's tables (unpack_level), put the heroes, missiles and views back to the start (reset_workspace), start the monsters dead and the heroes without keys (reset_monsters), then clear the screen, set the 6845 to show all 25 character rows the play screen uses, and draw the view frames and the four views (draw_view_frames). The order matters: any text printed before loading rewrites character 128's definition at &0C00, the start of room_walls, so the level is unpacked after it; and the level file lies in screen rows 23-24, so the screen is cleared only once the file is unpacked.
|
||||||||
| 1400 | .start_level←1← 0E57 JSR | |||||||
| JSR show_level_number ; Prepare the text area for the new level | ||||||||
| 1403 | JSR load_level ; Get the level file at &6B00 decrypted and checked | |||||||
| 1406 | JSR unpack_level ; Copy its objects, doors, keys and maps into play | |||||||
| 1409 | JSR reset_workspace ; Put the heroes, missiles and views back to the start | |||||||
| 140C | JSR reset_monsters ; Monsters to the trapdoors; heroes carry no keys | |||||||
| ; Show the play screen: clear the text area, display all 25 ; character rows, then draw the frames and the views. | ||||||||
| 140F | JSR clear_text_area ; Clear the screen, LEVEL and all, for the play screen | |||||||
| 1412 | LDA #&17 ; VDU 23,0,6,25,0,0,0,0,0,0: set 6845 register 6... | |||||||
| 1414 | JSR oswrch ; Send VDU 23 | |||||||
| 1417 | LDA #0 ; 0: a 6845 register setting follows | |||||||
| 1419 | JSR oswrch ; Send the 0 | |||||||
| 141C | LDA #6 ; Register 6: character rows displayed | |||||||
| 141E | JSR oswrch ; Send the register number | |||||||
| 1421 | LDA #&19 ; ...to 25: the views and panel fill rows 0-24 | |||||||
| 1423 | JSR oswrch ; Send it: show all 25 rows for play | |||||||
| 1426 | LDA #0 ; Six zero bytes complete the VDU 23 | |||||||
| 1428 | JSR oswrch ; Send the first zero | |||||||
| 142B | JSR oswrch ; Send the second zero | |||||||
| 142E | JSR oswrch ; Send the third zero | |||||||
| 1431 | JSR oswrch ; Send the fourth zero | |||||||
| 1434 | JSR oswrch ; Send the fifth zero | |||||||
| 1437 | JSR oswrch ; Send the sixth zero | |||||||
| 143A | LDA #<(view_frame_plots) ; (plot_x) points at the frames' PLOT commands... | |||||||
| 143C | STA plot_x ; ...low byte in plot_x... | |||||||
| 143E | LDA #>(view_frame_plots) ; ...and view_frame_plots' high byte... | |||||||
| 1440 | STA plot_y ; ...in plot_y, as draw_view_frames expects | |||||||
| 1442 | JSR draw_view_frames ; Draw the four frames, then the room in each view | |||||||
| 1445 | RTS ; Return to the level loop to draw the panel and play | |||||||
Load the level file from ROMFSBring the next level's file, LEVELn, from sideways RAM into &6B00-&6DAF, then decrypt and check it. Called by start_level once per level, after show_level_number has cleared the screen and counted level_number, and before unpack_level copies the level into play. The level file and the OSFILE block both lie in the screen's bottom two character rows, so the 6845 is first set to show only 23 rows (start_level restores 25 later). The block gets the address of level_filename, which level_loop has just written, and the load address &00006B00. Rather than calling OSFILE, the routine copies FILEV into the operand of its own JSR and calls that routine with A = &FF: it is the MOS's cassette and ROM filing system handler, since DUNK's loader leaves *ROM selected, and the ROM filing system finds LEVELn in the ROMFS images DUNK put in sideways RAM. It ends by jumping to decrypt_level, which returns to start_level, or resets the machine if the checksum is wrong. The block's byte 6 (the exec address's low byte, which must be 0 for the load address to be used) is not set here: it relies on show_level_number having cleared the screen, which the block lies in.
|
||||||||
| ; Show only 23 character rows, hiding rows 23-24, where the ; level file and the OSFILE block are about to go. | ||||||||
| 1446 | .load_level←1← 1403 JSR | |||||||
| LDA #&17 ; VDU 23,0,6,23,0,0,0,0,0,0: hide rows 23-24 while loading... | ||||||||
| 1448 | JSR oswrch ; Send VDU 23 | |||||||
| 144B | LDA #0 ; 0: a 6845 register setting follows | |||||||
| 144D | JSR oswrch ; Send the 0 | |||||||
| 1450 | LDA #6 ; ...register 6, rows displayed... | |||||||
| 1452 | JSR oswrch ; Send the register number | |||||||
| 1455 | LDA #&17 ; ...to 23 character rows displayed | |||||||
| 1457 | JSR oswrch ; Send it: the bottom two rows go blank while loading | |||||||
| 145A | LDA #0 ; ...then six zeros to finish the command | |||||||
| 145C | JSR oswrch ; Send the first zero of six | |||||||
| 145F | JSR oswrch ; Send the second zero | |||||||
| 1462 | JSR oswrch ; Send the third zero | |||||||
| 1465 | JSR oswrch ; Send the fourth zero | |||||||
| 1468 | JSR oswrch ; Send the fifth zero | |||||||
| 146B | JSR oswrch ; Send the sixth zero | |||||||
| ; Build the OSFILE block: the filename's address and the load ; address &00006B00. | ||||||||
| 146E | LDX #<(level_osfile_block) ; X, Y = address of the OSFILE block, in screen memory... | |||||||
| 1470 | LDY #>(level_osfile_block) ; ...&6E60, as OSFILE's routine expects | |||||||
| 1472 | LDA #<(level_filename) ; Filename address = level_filename ("LEVELn")... | |||||||
| 1474 | STA level_osfile_block ; ...in the block's bytes 0-1: low byte at 0... | |||||||
| 1477 | LDA #>(level_filename) ; ...and the name's page... | |||||||
| 1479 | STA level_osfile_block + 1 ; ...in the block's first two bytes | |||||||
| 147C | LDA #0 ; Load address = &00006B00... | |||||||
| 147E | STA level_osfile_block + 2 ; ...byte 0 is 0... | |||||||
| 1481 | STA level_osfile_block + 4 ; ...byte 2 is 0... | |||||||
| 1484 | STA level_osfile_block + 5 ; ...byte 3 is 0... | |||||||
| 1487 | LDA #>(level_object_x) ; ...byte 1 is &6B... | |||||||
| 1489 | STA level_osfile_block + 3 ; ...giving &00006B00, the start of the level buffer | |||||||
| ; Call FILEV's routine directly, through a JSR whose operand is ; set from FILEV, to load the file. | ||||||||
| 148C | LDA filev ; Copy FILEV into the operand of the JSR below... | |||||||
| 148F | STA filev_call_address ; ...the routine's low byte into the JSR... | |||||||
| 1492 | LDA filev + 1 ; ...and its page... | |||||||
| 1495 | STA filev_call_address + 1 ; ...so the JSR goes straight to the ROM filing system | |||||||
| 1498 | LDA #&ff ; A = &FF: load the file at the block's load address | |||||||
| ; Operand of the JSR at load_level_call. Stored as &3000; ; load_level overwrites it with the contents of FILEV before ; each call. | ||||||||
| 149A | .load_level_call | |||||||
| JSR &3000 ; Load LEVELn from ROMFS through FILEV's routine | ||||||||
| 149D | JMP decrypt_level ; Decrypt and check the level; it returns to start_level | |||||||
Reset the game workspace for a new levelPut the heroes, missiles and views back where every level starts. Called by start_level once a level, after unpack_level and before reset_monsters. Copy the 256 bytes of workspace_template (&7D00) over page &0D, the per-level workspace, then reset the exit animation's state, which lives in page &09: no hero going down the exit (exit_busy 0) or left shrunk (shrunk_hero &FF), the shrinking hero's pixel offsets (x 1, 1, 0, 0 and y 5, 3, 1, 0 for exit_shrinks_left 1-4), and trapdoor 0 as the next one a monster comes out of (next_trapdoor). Nothing here touches the heroes' health or scores, which carry over from level to level.
|
||||||||
| 14A0 | .reset_workspace←1← 1409 JSR | |||||||
| LDX #0 ; Copy workspace_template to page &0D | ||||||||
| 14A2 | .copy_workspace_template←1← 14A9 BNE | |||||||
| LDA workspace_template,x ; Byte of the starting values... | ||||||||
| 14A5 | STA scratch,x ; ...becomes page &0D's byte | |||||||
| 14A8 | INX ; Next of page &0D's 256 bytes | |||||||
| 14A9 | BNE copy_workspace_template ; Until all 256 are copied: heroes back at the start | |||||||
| 14AB | LDA #0 ; Reset the exit animation and the trapdoor turn | |||||||
| 14AD | STA exit_busy ; No hero is going down the exit | |||||||
| 14B0 | STA exit_offset_x_3 ; Shrinking hero's x offset at shrink 3: 0... | |||||||
| 14B3 | STA exit_offsets_y ; ...at shrink 4 (exit_offsets_y doubles as x 4)... | |||||||
| 14B6 | STA exit_offset_y_4 ; ...and the y offset at shrink 4 | |||||||
| 14B9 | STA next_trapdoor ; First monster emerges from trapdoor 0 | |||||||
| 14BC | LDA #1 ; Offsets of 1 for the exit animation | |||||||
| 14BE | STA exit_offset_x_1 ; ...x offset at shrink 1... | |||||||
| 14C1 | STA exit_offset_x_2 ; ...x offset at shrink 2... | |||||||
| 14C4 | STA exit_offset_y_3 ; ...and y offset at shrink 3 | |||||||
| 14C7 | LDA #&ff ; &FF: no hero is shrunk | |||||||
| 14C9 | STA shrunk_hero ; ...so no hero's sprites need restoring | |||||||
| 14CC | LDA #5 ; Shrinking hero's y offset at shrink 1: 5... | |||||||
| 14CE | STA exit_offset_y_1 ; ...for y offset 1 | |||||||
| 14D1 | LDA #3 ; ...and at shrink 2: 3 | |||||||
| 14D3 | STA exit_offset_y_2 ; ...for y offset 2 | |||||||
| 14D6 | RTS ; Return to start_level | |||||||
Draw the frames round the four viewsDraw the play screen's four view frames and the room in each view. Called last by start_level, with (plot_x) at view_frame_plots. WRCHV is first pointed back at the MOS's own routine (saved_wrchv), because wrch_handler swaps the code of any letter or digit for character 128, which would corrupt any PLOT coordinate byte that happens to be one. Then send the twenty five-byte commands as VDU 25s, call draw_all_views to draw the room each hero's view shows, and point WRCHV at wrch_handler again, so text that follows is in the game's font.
|
|||||||||||||||
| 14D7 | .draw_view_frames←1← 1442 JSR | ||||||||||||||
| LDA saved_wrchv ; Restore the MOS's own WRCHV for the PLOT commands... | |||||||||||||||
| 14DA | STA wrchv ; ...saved_wrchv's low byte into WRCHV... | ||||||||||||||
| 14DD | LDA saved_wrchv + 1 ; ...and its high byte... | ||||||||||||||
| 14E0 | STA wrchv + 1 ; ...so the PLOTs draw lines, not the game's font | ||||||||||||||
| 14E3 | LDX #&14 ; Twenty PLOT commands: five for each view's frame | ||||||||||||||
| 14E5 | .draw_view_frame←1← 1500 BNE | ||||||||||||||
| LDA #&19 ; Start a PLOT command: VDU 25... | |||||||||||||||
| 14E7 | JSR oswrch ; Send VDU 25: a PLOT command follows | ||||||||||||||
| 14EA | LDY #0 ; ...then the five bytes of the command | ||||||||||||||
| 14EC | .send_frame_vdu←1← 14F4 BNE | ||||||||||||||
| LDA (plot_x),y ; Next byte of this PLOT: K, then X and Y | |||||||||||||||
| 14EE | JSR oswrch ; Send it to the VDU drivers | ||||||||||||||
| 14F1 | INY ; On to the command's next byte | ||||||||||||||
| 14F2 | CPY #5 ; All five sent? | ||||||||||||||
| 14F4 | BNE send_frame_vdu ; No: send the next | ||||||||||||||
| 14F6 | CLC ; Step (plot_x) on to the next command... | ||||||||||||||
| 14F7 | LDA plot_x ; ...its low byte... | ||||||||||||||
| 14F9 | ADC #5 ; ...plus five... | ||||||||||||||
| 14FB | STA plot_x ; ...to the next PLOT (the table is all in one page) | ||||||||||||||
| 14FD | LDY #0 ; Start the next PLOT at its first byte | ||||||||||||||
| 14FF | DEX ; Count the PLOT done | ||||||||||||||
| 1500 | BNE draw_view_frame ; Until all twenty are drawn | ||||||||||||||
| 1502 | JSR draw_all_views ; Draw each hero's room inside their frame | ||||||||||||||
| 1505 | LDA #<(wrch_handler) ; Point WRCHV back at wrch_handler... | ||||||||||||||
| 1507 | STA wrchv ; ...its low byte into WRCHV... | ||||||||||||||
| 150A | LDA #>(wrch_handler) ; ...and its high byte... | ||||||||||||||
| 150C | STA wrchv + 1 ; ...so text is drawn in the game's font again | ||||||||||||||
| 150F | RTS ; Return to start_level: frames and views drawn | ||||||||||||||
Copy the loaded level into the game's tablesBring the level just loaded into play. Called by start_level once the level file at &6B00 has been decrypted and checked, before reset_workspace. Copy objects 1-30 (position and type; the type is also the sprite), doors 1-20 (position and sprite), keys 1-20, trapdoors 0-7, &C9 bytes each of the wall map (into room_walls, read by test_wall) and object-free map (into object_free_map, read by test_object_free), and the level's 4 x 12 wall block into wall_sprite, sprite 0, the wall in every room. Entry 0 of the object, door and key tables is not touched. room_walls is also character 128's definition, which the game's text output overwrites, so this must follow the printing of the level number. The file itself lies in screen rows 23-24 and is wiped by start_level's clear_text_area once unpacked.
|
||||||||
| 1510 | .unpack_level←1← 1406 JSR | |||||||
| LDX #max_object ; Objects 30 to 1: position and type | ||||||||
| 1512 | .unpack_objects←1← 1525 BNE | |||||||
| LDA level_object_x,x ; Object's x in the level file... | ||||||||
| 1515 | STA object_x,x ; ...becomes its map x | |||||||
| 1518 | LDA level_object_y,x ; The object's y in the file... | |||||||
| 151B | STA object_y,x ; ...becomes its map y | |||||||
| 151E | LDA level_object_type,x ; Its type, which is also its sprite... | |||||||
| 1521 | STA object_type,x ; ...becomes its object type | |||||||
| 1524 | DEX ; Next object down | |||||||
| 1525 | BNE unpack_objects ; Until object 1 is done (entry 0 is unused) | |||||||
| 1527 | LDX #max_door ; Doors 20 to 1: position and sprite | |||||||
| 1529 | .unpack_doors←1← 153C BNE | |||||||
| LDA level_door_x,x ; Door's x in the level file... | ||||||||
| 152C | STA door_x,x ; ...becomes its map x | |||||||
| 152F | LDA level_door_y,x ; The door's y in the file... | |||||||
| 1532 | STA door_y,x ; ...becomes its map y | |||||||
| 1535 | LDA level_door_sprite,x ; Its sprite, upright or across... | |||||||
| 1538 | STA door_sprite,x ; ...becomes its sprite | |||||||
| 153B | DEX ; Next door down | |||||||
| 153C | BNE unpack_doors ; Until door 1 is done | |||||||
| 153E | LDX #max_key ; Keys 20 to 1: position | |||||||
| 1540 | .unpack_keys←1← 154D BNE | |||||||
| LDA level_key_x,x ; Key's x in the level file... | ||||||||
| 1543 | STA key_x,x ; ...becomes its map x | |||||||
| 1546 | LDA level_key_y,x ; The key's y in the file... | |||||||
| 1549 | STA key_y,x ; ...becomes its map y | |||||||
| 154C | DEX ; Next key down | |||||||
| 154D | BNE unpack_keys ; Until key 1 is done | |||||||
| 154F | LDX #0 ; Trapdoors 0 to 7: where dead monsters come back | |||||||
| 1551 | .unpack_trapdoors←1← 1560 BNE | |||||||
| LDA level_trapdoor_x,x ; Trapdoor's x in the level file... | ||||||||
| 1554 | STA trapdoor_x,x ; ...becomes its map x | |||||||
| 1557 | LDA level_trapdoor_y,x ; The trapdoor's y in the file... | |||||||
| 155A | STA trapdoor_y,x ; ...becomes its map y | |||||||
| 155D | INX ; Next trapdoor up, 0 to 7 | |||||||
| 155E | CPX #8 ; All eight done? | |||||||
| 1560 | BNE unpack_trapdoors ; No: copy the next | |||||||
| 1562 | LDX #0 ; Wall map and object-free map, &C9 bytes each | |||||||
| 1564 | .unpack_walls←1← 1573 BNE | |||||||
| LDA level_walls,x ; Byte of the level's wall map... | ||||||||
| 1567 | STA room_walls,x ; ...into room_walls, which test_wall reads | |||||||
| 156A | LDA level_object_free_map,x ; Byte of the level's object-free map... | |||||||
| 156D | STA object_free_map,x ; ...into object_free_map, which test_object_free reads | |||||||
| 1570 | INX ; Next byte of both maps | |||||||
| 1571 | CPX #map_bytes ; Both maps copied? | |||||||
| 1573 | BNE unpack_walls ; No: copy the next | |||||||
| 1575 | LDX #0 ; The level's own wall block, &30 bytes | |||||||
| 1577 | .unpack_wall_sprite←1← 1580 BNE | |||||||
| LDA level_wall_sprite,x ; Byte of the level's wall block... | ||||||||
| 157A | STA wall_sprite,x ; ...becomes sprite 0, the wall in every room | |||||||
| 157D | INX ; Next byte of the wall block | |||||||
| 157E | CPX #&30 ; All 4 x 12 bytes copied? | |||||||
| 1580 | BNE unpack_wall_sprite ; No: copy the next | |||||||
| 1582 | RTS ; Return to start_level with the level unpacked | |||||||
Clear the monsters for a new levelStart every monster dead and every hero empty-handed. Called by start_level after reset_workspace. Give monsters 1-30 the blank sprite (the first stage of dying) and an x off the map, so update_monsters brings each out of a trapdoor in turn, with monster_start_hit_points, the hit points level_loop set for this level. Then, for each of the four heroes, clear their returning_hero_queue entry, the key they carry (hero_key) and the swap flag (hero_key_dropped), and the cell kept for the door and Chalice checks (hero_door_x, hero_door_y), so nothing from the last level opens a door or wins the game. remove_absent_heroes refills the queue later for heroes nobody plays.
|
||||||||
| 1583 | .reset_monsters←1← 140C JSR | |||||||
| LDX #max_monster ; Monsters 30 to 1... | ||||||||
| 1585 | .reset_each_monster←1← 1596 BNE | |||||||
| LDA #spr_blank ; ...dying, so that they emerge from the trapdoors... | ||||||||
| 1587 | STA monster_sprite,x ; ...as monster X's sprite... | |||||||
| 158A | LDA #off_map ; ...off the map... | |||||||
| 158C | STA monster_x,x ; ...as monster X's x... | |||||||
| 158F | LDA monster_start_hit_points ; ...with this level's hit points | |||||||
| 1592 | STA monster_hit_points,x ; ...as monster X's hit points | |||||||
| 1595 | DEX ; Next monster down | |||||||
| 1596 | BNE reset_each_monster ; Until monster 1 is done | |||||||
| 1598 | LDX #0 ; Each hero: clear queue place, key carried, door cell | |||||||
| 159A | LDA #0 ; Zero for every entry cleared | |||||||
| 159C | .clear_hero_carrying←1← 15AE BNE | |||||||
| STA returning_hero_queue,x ; Queue entry X empty: nobody waits to return | ||||||||
| 159F | STA hero_key,x ; Hero X carries no key | |||||||
| 15A2 | STA hero_key_dropped,x ; ...and has swapped none | |||||||
| 15A5 | STA hero_door_x,x ; No door-check cell... | |||||||
| 15A8 | STA hero_door_y,x ; ...in x or y | |||||||
| 15AB | INX ; Next hero, 0 to 3 | |||||||
| 15AC | CPX #4 ; All four done? | |||||||
| 15AE | BNE clear_hero_carrying ; No: clear the next | |||||||
| 15B0 | RTS ; Return to start_level, monsters and heroes reset | |||||||
Show the number of the level about to startShow "LEVEL nn" while the level loads. Called first by start_level, before the level file is loaded. Clear the screen (clear_text_area), count the level in level_number (level_loop has already counted level_bcd), plot the LEVEL sprite at byte column 27, pixel row 40, and print the two BCD digits after it at TAB(10,5) in colour 6 through wrch_handler, so in the game's font; levels 1-9 show a leading 0. Then set a text window over columns 1-14, rows 17-22, and colour 2: the setting in force while the level loads, until start_level clears the screen again. Printing the digits rewrites character 128's definition at &0C00, which unpack_level later overwrites with the wall map.
|
||||||||
| 15B1 | .show_level_number←1← 1400 JSR | |||||||
| JSR clear_text_area ; Clear the screen for the level-number display | ||||||||
| 15B4 | LDA #&11 ; Text colour 6 for the number: VDU 17... | |||||||
| 15B6 | JSR oswrch ; Send VDU 17: set the text colour | |||||||
| 15B9 | LDA #6 ; Colour 6: the level number's colour | |||||||
| 15BB | JSR oswrch ; Send it: the digits print in colour 6 | |||||||
| 15BE | INC level_number ; Count the level in level_number, 1-25 | |||||||
| ; Plot the word LEVEL, then print the level's two BCD digits ; just to its right. | ||||||||
| 15C1 | LDA #&1b ; Plot the word LEVEL... | |||||||
| 15C3 | STA plot_x ; ...at byte column 27, as plot_x... | |||||||
| 15C5 | LDA #&28 ; ...pixel row 40, character row 5... | |||||||
| 15C7 | STA plot_y ; ...as plot_y: the top of character row 5 | |||||||
| 15C9 | LDA #spr_level_word ; ...the word LEVEL's sprite... | |||||||
| 15CB | STA sprite_number ; ...as the sprite to plot | |||||||
| 15CD | JSR plot_sprite ; Plot it, 12 bytes wide, 8 rows high | |||||||
| 15D0 | LDA #&1f ; TAB(10,5)... | |||||||
| 15D2 | JSR oswrch ; Send VDU 31: move the text cursor | |||||||
| 15D5 | LDA #&0a ; Column 10: byte column 40, just past LEVEL's 27-38 | |||||||
| 15D7 | JSR oswrch ; Send the column | |||||||
| 15DA | LDA #5 ; ...row 5: level with LEVEL | |||||||
| 15DC | JSR oswrch ; Send the row: the digits go just right of LEVEL | |||||||
| 15DF | LDA level_bcd ; The level in BCD, tens digit first... | |||||||
| 15E2 | TAY ; Keep the BCD level for the units | |||||||
| 15E3 | LSR ; Tens digit = level_bcd >> 4: shift 1... | |||||||
| 15E4 | LSR ; ...shift 2... | |||||||
| 15E5 | LSR ; ...shift 3... | |||||||
| 15E6 | LSR ; ...shift 4: the tens, 0-2 | |||||||
| 15E7 | CLC ; Clear the carry for the add | |||||||
| 15E8 | ADC #'0' ; Make it an ASCII digit, '0' for levels 1-9 | |||||||
| 15EA | JSR oswrch ; Print it; wrch_handler draws it in the game's font | |||||||
| 15ED | TYA ; Print the units digit... | |||||||
| 15EE | AND #&0f ; Keep only the units digit | |||||||
| 15F0 | CLC ; Clear the carry for the add | |||||||
| 15F1 | ADC #'0' ; Make it an ASCII digit | |||||||
| 15F3 | JSR oswrch ; Print it after the tens | |||||||
| ; Leave a small text window and colour 2 in force while the ; level loads. | ||||||||
| 15F6 | LDA #&1c ; VDU 28,1,22,14,17: the window used while loading... | |||||||
| 15F8 | JSR oswrch ; Send VDU 28 | |||||||
| 15FB | LDA #1 ; Left column 1 | |||||||
| 15FD | JSR oswrch ; Send the left column | |||||||
| 1600 | LDA #&16 ; Bottom row 22 | |||||||
| 1602 | JSR oswrch ; Send the bottom row | |||||||
| 1605 | LDA #&0e ; Right column 14 | |||||||
| 1607 | JSR oswrch ; Send the right column | |||||||
| 160A | LDA #&11 ; ...top row 17 | |||||||
| 160C | JSR oswrch ; ...send the window's top row | |||||||
| 160F | LDA #&11 ; COLOUR 2: text in colour 2 from now on... | |||||||
| 1611 | JSR oswrch ; ...send VDU 17 (COLOUR) | |||||||
| 1614 | LDA #2 ; Colour 2 for any text while the level loads | |||||||
| 1616 | JSR oswrch ; Send it: VDU 17,2 complete | |||||||
| 1619 | RTS ; Return to start_level to load the level | |||||||
Clear the screenClear the screen above the game code. Called twice for each level: by the routine start_level calls first, before the level is loaded, and by start_level itself before the play screen is drawn. Set a text window the full 20 columns wide from row 0 to the bottom row (24 in play), and clear it with VDU 12. The window never reaches below row 24 because MODE 2's rows 25-31, &6E80-&7FFF, hold game code. The window is left set, so later text and clears stay inside it.
|
||||||||
| 161A | .clear_text_area←2← 140F JSR← 15B1 JSR | |||||||
| LDA #&1c ; VDU 28: a text window over the whole screen... | ||||||||
| 161C | JSR oswrch ; Send VDU 28 | |||||||
| 161F | LDA #0 ; Left column 0 | |||||||
| 1621 | JSR oswrch ; Send the left column | |||||||
| 1624 | LDA #&18 ; Bottom row of the window (24 in play) | |||||||
| 1626 | JSR oswrch ; Send the bottom row | |||||||
| 1629 | LDA #&13 ; Right column 19: the full MODE 2 width | |||||||
| 162B | JSR oswrch ; Send the right column | |||||||
| 162E | LDA #0 ; Top row 0 | |||||||
| 1630 | JSR oswrch ; Send the top row | |||||||
| 1633 | LDA #&0c ; ...VDU 12 to clear it | |||||||
| 1635 | JSR oswrch ; Send it: the window clears to the background | |||||||
| 1638 | RTS ; Return with the window left set | |||||||
| 1639 | EQUB &60 ; Not referenced | |||||||
View frame PLOT commandsTwenty five-byte VDU 25 commands (plot code, then x and y as 16-bit words) sent by draw_view_frames, five for each view's frame: PLOT 4 moves to the top-left corner, three PLOT 1s draw relative lines down 388, right 520 and up 388, and PLOT 5 draws back to the corner. The corners are (8,1022), (552,1022), (8,614) and (552,614); the second frame's first line is 389 long. |
|
| ; Twenty VDU 25 (PLOT) commands, five bytes each (plot code, ; then x and y as 16-bit words), that draw the frames round the ; four views; read by draw_view_frames through (plot_x). | |
| 163A | .view_frame_plots |
| EQUB &04, &08, &00, &FE, &03, &01, &00, &00, &7C, &FE, &01, &08, &02, &00, &00, &01, &00, &00, &84, &01, &05, &08, &00, &FE, &03, &04, &28, &02, &FE, &03, &01, &00, &00, &7B, &FE, &01, &08, &02, &00, &00, &01, &00, &00, &84, &01, &05, &28, &02, &FE, &03, &04, &08, &00, &66, &02, &01, &00, &00, &7C, &FE, &01, &08, &02, &00, &00, &01, &00, &00, &84, &01, &05, &08, &00, &66, &02, &04, &28, &02, &66, &02, &01, &00, &00, &7C, &FE, &01, &08, &02, &00, &00, &01, &00, &00, &84, &01, &05, &28, &02, &66, &02 | |
| 169E | EQUB &08 ; Not referenced |
| ; The current level, 1-25, in binary. Set to 0 for a new game ; and counted up as each level starts. Read for the monsters' ; hit points (8 + 2 per level already played), for the level ; file's checksum entry (decrypt_level), and by ; check_for_victory, which looks for the Chalice only on level ; 25. | |
| 169F | .level_number←6← 0477 LDX← 0E02 STA← 0E14 LDA← 0E29 LDA← 1070 LDA← 15BE INC |
| EQUB &01 | |
Sound the exit and add a queue markerPlay the exit's falling tone and queue a marker for the hero leaving. Called first by hero_enters_exit, when a hero steps onto the exit. Define envelope 3 from exit_envelope and play exit_sound with it (channel 2, pitch 250). Then put a &64 (nobody_returns) entry in the first empty (zero) entry of returning_hero_queue, behind any dead heroes waiting, as remove_absent_heroes does for each hero nobody plays. A Cross of Resurrection passes such markers to the back of the queue, so a hero who took the exit is never brought back by one. At most four of the queue's five entries are ever in use, so an empty one is always found; X is not bounded.
|
||||||||
| 16A0 | .queue_exit_marker←1← 203D JSR | |||||||
| LDX #<(exit_envelope) ; Envelope 3 for the exit: X = exit_envelope low... | ||||||||
| 16A2 | LDY #>(exit_envelope) ; ...Y = its high byte... | |||||||
| 16A4 | LDA #osword_envelope ; ...OSWORD 8: ENVELOPE... | |||||||
| 16A6 | JSR osword ; Define envelope 3: a falling pitch ENVELOPE command | |||||||
| 16A9 | LDX #<(exit_sound) ; Play the exit sound: X = exit_sound low... | |||||||
| 16AB | LDY #>(exit_sound) ; ...Y = its high byte... | |||||||
| 16AD | LDA #osword_sound ; ...OSWORD 7: SOUND... | |||||||
| 16AF | JSR osword ; Sound channel 2 with envelope 3 SOUND command | |||||||
| 16B2 | LDX #0 ; Append a marker to returning_hero_queue... | |||||||
| 16B4 | .find_queue_end←1← 16C0 BNE | |||||||
| LDA returning_hero_queue,x ; Entry X of the queue | ||||||||
| 16B7 | BNE next_queue_entry ; In use: try the next | |||||||
| 16B9 | LDA #nobody_returns ; Empty: add a &64 marker there | |||||||
| 16BB | STA returning_hero_queue,x ; ...in the first empty entry, behind those waiting | |||||||
| 16BE | RTS ; Return to hero_enters_exit | |||||||
| 16BF | .next_queue_entry←1← 16B7 BNE | |||||||
| INX ; Next entry along the queue | ||||||||
| 16C0 | BNE find_queue_end ; Keep looking (at most four entries are in use) | |||||||
| 16C2 | EQUB &02, &02, &00, &00, &83, &00, &00, &00, &00, &00, &00, &31, &00, &8D ; Not referenced | |||||||
| ; The level's filename for ROMFS: "LEVEL", then the level number ; in one or two ASCII digits (level_filename_digits) and a ; carriage return. level_loop writes the digits and the CR ; before each level; load_level puts the name's address in ; level_osfile_block, and the ROM filing system reads it from ; there. | ||||||||
| 16D0 | .level_filename | |||||||
| EQUS "LEVEL" | ||||||||
| ; Where the level number's digits are written into the level's ; filename. | ||||||||
| 16D5 | .level_filename_digits←2Referenced by← 0E4F STAUsed as index base by← 0E3E STA | |||||||
| EQUB &31 | ||||||||
| 16D6 | EQUB &0D, ; The second digit and CR, or the CR after one &0D ; digit | |||||||
| 16D8 | EQUB &70, &00, &8D, &35, &F8, &00, &00, &00, ; Not &00 ; referenced | |||||||
| 16E1 | EQUS "code" | |||||||
| 16E5 | EQUB &00, &54, &12, &03, &17, &74, &00, &8C, &50, &00, &00, &00, &FA, &16, &78, &00, &8C, &50, &20, &00, &00, &02, &00, &79, &00, &8C ; Not referenced | |||||||
| ; The current level in binary-coded decimal (&01-&25), counted ; up with decimal arithmetic as each level starts, for printing ; the level number and for the digits of the level's filename. | ||||||||
| 16FF | .level_bcd←6← 0E05 STA← 0E20 LDA← 0E25 STA← 0E36 LDA← 0E45 LDA← 15DF LDA | |||||||
| EQUB &01 | ||||||||
| fall through ↓ | ||||||||
Sword spritesSprites &49-&4C, the Fighter's missile flying up, right, down and left: 4 bytes by 12 rows each. |
|
| ; Data of sprite &49: 4 bytes x 12 rows. | |
| 1700 | .sprite_sword_up |
| EQUB &00, &00, &00, &00, &00, &15, &00, &00, &00, &15, &00, &00, &00, &15, &00, &00, &00, &15, &00, &00, &00, &15, &00, &00, &00, &15, &00, &00, &00, &15, &00, &00, &00, &03, &02, &00, &00, &01, &00, &00, &00, &01, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &4A: 4 bytes x 12 rows. | |
| 1730 | .sprite_sword_right |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &01, &00, &00, &01, &03, &3F, &3F, &00, &01, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &4B: 4 bytes x 12 rows. | |
| 1760 | .sprite_sword_down |
| EQUB &00, &00, &00, &00, &00, &00, &02, &00, &00, &00, &02, &00, &00, &01, &03, &00, &00, &00, &2A, &00, &00, &00, &2A, &00, &00, &00, &2A, &00, &00, &00, &2A, &00, &00, &00, &2A, &00, &00, &00, &2A, &00, &00, &00, &2A, &00, &00, &00, &00, &00 | |
| ; Data of sprite &4C: 4 bytes x 12 rows. | |
| 1790 | .sprite_sword_left |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &02, &00, &3F, &3F, &03, &02, &00, &00, &02, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
UnusedLeftover bytes, never read, including fragments of BASIC text ("?&A66=(rx%-lx%)", "sprite%?&A99=by%-ty%+1"). |
|
| 17C0 | EQUB &80, &00, &00, &32, &00 ; Not referenced |
| 17C5 | EQUS "eco" |
| 17C8 | EQUB &00, &8E, &0B, &94, &00, &00 ; Not referenced |
| 17CE | EQUS "?&A66=(rx%-lx%)" |
| 17DD | EQUB &81 ; Not referenced |
| 17DE | EQUS "2+1:sprite%?&A99=by%-ty%+1" |
| 17F8 | EQUB &0D, &03, &D4, &1D, ; Not referenced &20, &D4, &31, &2C |
Panel sprites: the shield and the small digitsSprite &69, the shield beside each hero's face in the status panel (3 bytes by 12 rows), then sprites &6A-&72, the small digits 1-9 (1 byte by 5 rows), which show the armour rating on the shield and the missile damage. |
|
| ; Data of sprite &69: 3 bytes x 12 rows. | |
| 1800 | .sprite_shield |
| EQUB &3F, &3F, &3E, &2A, &00, &14, &2A, &00, &14, &2A, &00, &14, &2A, &00, &14, &2A, &00, &14, &2A, &00, &14, &2A, &00, &14, &15, &00, &28, &15, &00, &28, &00, &3E, &00, &00, &3E, &00 | |
| ; Data of sprite &6A: 1 bytes x 5 rows. | |
| 1824 | .sprite_small_digit_1 |
| EQUB &01, &01, &01, &01, &01 | |
| ; Data of sprite &6B: 1 bytes x 5 rows. | |
| 1829 | .sprite_small_digit_2 |
| EQUB &03, &01, &03, &02, &03 | |
| ; Data of sprite &6C: 1 bytes x 5 rows. | |
| 182E | .sprite_small_digit_3 |
| EQUB &03, &01, &03, &01, &03 | |
| ; Data of sprite &6D: 1 bytes x 5 rows. | |
| 1833 | .sprite_small_digit_4 |
| EQUB &02, &02, &03, &03, &01 | |
| ; Data of sprite &6E: 1 bytes x 5 rows. | |
| 1838 | .sprite_small_digit_5 |
| EQUB &03, &02, &03, &01, &03 | |
| ; Data of sprite &6F: 1 bytes x 5 rows. | |
| 183D | .sprite_small_digit_6 |
| EQUB &02, &02, &03, &03, &03 | |
| ; Data of sprite &70: 1 bytes x 5 rows. | |
| 1842 | .sprite_small_digit_7 |
| EQUB &03, &01, &01, &01, &01 | |
| ; Data of sprite &71: 1 bytes x 5 rows. | |
| 1847 | .sprite_small_digit_8 |
| EQUB &03, &03, &03, &03, &03 | |
| ; Data of sprite &72: 1 bytes x 5 rows. | |
| 184C | .sprite_small_digit_9 |
| EQUB &03, &03, &03, &01, &01 | |
| 1851 | EQUB &0A, &00, &05, &00, &00, &00, &0A, &00, &05, &00, &00, &00, &0A, &00, &05 ; Not referenced |
Panel sprites: the missile and boots iconsSprite &74, the missile icon, one per missile a hero may have in flight (4 bytes by 3 rows), and sprite &75, the boots icon shown while a hero wears the Boots of Speed (2 bytes by 6 rows). |
|
| ; Data of sprite &74: 4 bytes x 3 rows. | |
| 1860 | .sprite_missile_icon |
| EQUB &00, &00, &01, &00, &3F, &3F, &2B, &03, &00, &00, &01, &00 | |
| ; Data of sprite &75: 2 bytes x 6 rows. | |
| 186C | .sprite_boots_icon |
| EQUB &00, &05, &00, &0A, &05, &00, &00, &0A, &05, &00, &0A, &00 | |
The word LEVELSprite &76, the word LEVEL for the level-number display: 12 bytes by 8 rows. |
|
| ; Data of sprite &76: 12 bytes x 8 rows. | |
| 1878 | .sprite_level_word |
| EQUB &3C, &00, &14, &3C, &28, &28, &14, &14, &3C, &28, &3C, &00, &3C, &00, &14, &00, &00, &28, &14, &14, &00, &00, &3C, &00, &3C, &00, &14, &3C, &28, &3C, &3C, &14, &3C, &28, &3C, &00, &3C, &3C, &14, &00, &00, &3C, &3C, &14, &00, &00, &3C, &3C, &3C, &3C, &14, &3C, &28, &3C, &3C, &14, &3C, &28, &3C, &3C, &3C, &3C, &14, &3C, &28, &14, &28, &14, &3C, &28, &3C, &3C, &3C, &3C, &14, &3C, &28, &14, &28, &14, &3C, &28, &3C, &3C, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| 18D8 | EQUB &08, &00, &04, &00, &00, &00, &08, &04, &00, &00, &08, &00, &0C, &0C, &04, &0C, &08, &00, &08, &04, &0C, &08, &0C, &0C, &1A, &35, &03, &8F, &7D, &9A, &82, &03, &00, &00, &00, &6D, &19, &00, &00, &00 ; Not referenced |
| ; OSWORD 8 (ENVELOPE) parameter block for casting magic. | |
| 1900 | .magic_envelope |
| EQUB &03 ; Envelope 3 | |
| 1901 | EQUB &01 ; Step length 1 centisecond |
| 1902 | EQUB &0A, &0A, ; Pitch change per step in sections 1-3: 10, &EC ; 10, -20 |
| 1905 | EQUB &03, &03, &03 ; Steps in pitch sections 1-3: 3, 3, 3 |
| 1908 | EQUB &80, &00, ; Amplitude change per step in attack, &00, &FF ; decay, sustain, release: -128, 0, 0, -1 |
| 190C | EQUB &80, ; Target levels at the end of attack and decay: &80 ; 128, 128 |
| ; OSWORD 7 (SOUND) parameter block for casting magic. | |
| 190E | .magic_sound |
| EQUW &12, &03, 0, ; SOUND channel 2 (flush), envelope 3, 2 ; pitch 0, duration 2 | |
| ; OSWORD 8 (ENVELOPE) parameter block for collecting treasure. | |
| 1916 | .treasure_envelope |
| EQUB &03 ; Envelope 3 | |
| 1917 | EQUB &02 ; Step length 2 centiseconds |
| 1918 | EQUB &01, &01, ; Pitch change per step in sections 1-3: 1, &01 ; 1, 1 |
| 191B | EQUB &01, &01, &01 ; Steps in pitch sections 1-3: 1, 1, 1 |
| 191E | EQUB &80, &00, ; Amplitude change per step in attack, &00, &F8 ; decay, sustain, release: -128, 0, 0, -8 |
| 1922 | EQUB &80, ; Target levels at the end of attack and decay: &80 ; 128, 128 |
| ; OSWORD 7 (SOUND) parameter block for collecting treasure. | |
| 1924 | .treasure_sound |
| EQUW &12, &03, ; SOUND channel 2 (flush), envelope 3, pitch 200, 5 ; 200, duration 5 | |
| ; OSWORD 8 (ENVELOPE) parameter block for collecting an item. | |
| 192C | .pickup_envelope |
| EQUB &03 ; Envelope 3 | |
| 192D | EQUB &80 ; Step length 0 centiseconds, no auto-repeat |
| 192E | EQUB &00, &00, ; Pitch change per step in sections 1-3: 0, &00 ; 0, 0 |
| 1931 | EQUB &0A, &0A, ; Steps in pitch sections 1-3: 10, 10, 10 &0A |
| 1934 | EQUB &0A, &00, ; Amplitude change per step in attack, &00, &FD ; decay, sustain, release: 10, 0, 0, -3 |
| 1938 | EQUB &80, ; Target levels at the end of attack and decay: &80 ; 128, 128 |
| ; OSWORD 7 (SOUND) parameter block for collecting an item. | |
| 193A | .pickup_sound |
| EQUW &10, &03, 10, ; SOUND channel 0 (flush), envelope 3, 5 ; pitch 10, duration 5 | |
| ; OSWORD 8 (ENVELOPE) parameter block for picking up a key. | |
| 1942 | .key_envelope |
| EQUB &03 ; Envelope 3 | |
| 1943 | EQUB &80 ; Step length 0 centiseconds, no auto-repeat |
| 1944 | EQUB &00, &00, ; Pitch change per step in sections 1-3: 0, &00 ; 0, 0 |
| 1947 | EQUB &01, &1E, &1E ; Steps in pitch sections 1-3: 1, 30, 30 |
| 194A | EQUB &80, &00, ; Amplitude change per step in attack, &00, &FE ; decay, sustain, release: -128, 0, 0, -2 |
| 194E | EQUB &80, ; Target levels at the end of attack and decay: &80 ; 128, 128 |
| ; OSWORD 7 (SOUND) parameter block for picking up a key. | |
| 1950 | .key_sound |
| EQUW &12, &03, ; SOUND channel 2 (flush), envelope 3, pitch 240, 1 ; 240, duration 1 | |
| ; OSWORD 8 (ENVELOPE) parameter block for a hero going down the ; exit. | |
| 1958 | .exit_envelope |
| EQUB &03 ; Envelope 3 | |
| 1959 | EQUB &82 ; Step length 2 centiseconds, no auto-repeat |
| 195A | EQUB &FF, &FF, ; Pitch change per step in sections 1-3: -1, &FE ; -1, -2 |
| 195D | EQUB &01, &01, &80 ; Steps in pitch sections 1-3: 1, 1, 128 |
| 1960 | EQUB &80, &00, ; Amplitude change per step in attack, &00, &FF ; decay, sustain, release: -128, 0, 0, -1 |
| 1964 | EQUB &80, ; Target levels at the end of attack and decay: &80 ; 128, 128 |
| ; OSWORD 7 (SOUND) parameter block for a hero going down the ; exit. | |
| 1966 | .exit_sound |
| EQUW &12, &03, ; SOUND channel 2 (flush), envelope 3, pitch 250, 1 ; 250, duration 1 | |
| 196E | EQUB &00, &00, &00, &00, &04 ; Not referenced |
| 1973 | EQUS "50:50:$" |
| 197A | EQUB &0C, &0C, &08, &00, &00, &00, &00, &00, ; Not &00, &00, &00, &00, &0A, &00, &00, &00, ; referenced &00, &14, &34, &38, &03, &03 |
| 1990 | EQUS "4<:%" |
| 1994 | EQUB &0F, &0F, &0F, &1E, &31, &38, &03 ; Not referenced |
| 199B | EQUS "48<" |
| 199E | EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &04 ; Not referenced |
| 19AB | EQUS "5?:" |
| 19AE | EQUB &18, &3F, &3A, &0C, &0C, &08, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &35, &00 ; Not referenced |
Hero and death spritesSprite &08, the Ranger facing left (second frame), then sprites &64-&68, the skulls of a hero's death animation, the last of which is left where the hero fell; 4 bytes by 12 rows each. |
|
| ; Data of sprite &08: 4 bytes x 12 rows. | |
| 19C0 | .sprite_ranger_left_1 |
| EQUB &00, &01, &03, &00, &01, &0B, &08, &00, &01, &0E, &0C, &00, &03, &06, &3C, &00, &02, &03, &25, &28, &02, &05, &0F, &3C, &02, &05, &0F, &3C, &02, &00, &25, &29, &00, &00, &3C, &09, &00, &0A, &0C, &09, &00, &0E, &0C, &00, &00, &04, &00, &00 | |
| ; Data of sprite &64: 4 bytes x 12 rows. | |
| 19F0 | .sprite_skull_0 |
| EQUB &00, &00, &00, &00, &00, &3F, &00, &00, &00, &00, &00, &00, &15, &15, &2A, &2A, &2A, &3F, &3F, &15, &2A, &3F, &3F, &15, &2A, &35, &3A, &15, &2A, &15, &2A, &15, &2A, &00, &00, &2A, &2A, &00, &3F, &2A, &15, &00, &00, &2A, &15, &00, &00, &00 | |
| ; Data of sprite &65: 4 bytes x 12 rows. | |
| 1A20 | .sprite_skull_1 |
| EQUB &15, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &15, &15, &2A, &2A, &2A, &3F, &3F, &2A, &2A, &35, &3A, &15, &2A, &35, &3A, &15, &2A, &3F, &3F, &15, &00, &00, &00, &00, &00, &00, &00, &2A, &2A, &00, &00, &2A, &15, &15, &2A, &2A | |
| ; Data of sprite &66: 4 bytes x 12 rows. | |
| 1A50 | .sprite_skull_2 |
| EQUB &00, &00, &00, &00, &00, &2A, &00, &00, &15, &00, &00, &00, &2A, &3F, &3F, &00, &00, &35, &35, &00, &15, &35, &35, &00, &15, &3F, &3F, &00, &15, &3A, &20, &15, &15, &00, &00, &15, &00, &2A, &00, &3F, &2A, &15, &15, &15, &15, &00, &2A, &00 | |
| ; Data of sprite &67: 4 bytes x 12 rows. | |
| 1A80 | .sprite_skull_3 |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &15, &00, &00, &00, &3F, &2A, &00, &00, &35, &20, &00, &15, &35, &20, &2A, &3F, &3F, &3F, &00, &15, &3A, &2A, &15, &15, &00, &00, &2A, &15, &2A, &15, &00, &15, &3F, &2A, &00, &2A, &15, &3F, &2A | |
| ; Data of sprite &68: 4 bytes x 12 rows. | |
| 1AB0 | .sprite_skull_4 |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &15, &3F, &00, &00, &10, &3A, &00, &00, &10, &3A, &00, &00, &15, &3F, &15, &2A, &3F, &35, &2A, &15, &2A, &2A, &00, &00, &3F, &3F, &2A, &3F, &15, &2A, &15 | |
Run one frame of playDo all of a frame's play apart from the exit. Called by play_level once a frame, after check_for_victory; play_level deals with the exit when this returns. The work, in order:
|
||||||||
| 1CC0 | .update_game←1← 1F0D JSR | |||||||
| JSR move_heroes ; Move the heroes: steps, shots, magic, pick-ups | ||||||||
| ; Doors: for each hero, find a door at the cell they last ; stepped or tried to step into, and open it if they carry its ; key. | ||||||||
| 1CC3 | LDX #0 ; For each hero, 0-3... | |||||||
| 1CC5 | .check_doors←1← 1DBF JMP | |||||||
| STX scratch ; ...hero number in scratch, for the door's points | ||||||||
| 1CC8 | LDA hero_door_x,x ; The cell hero X last stepped or bumped into... | |||||||
| 1CCB | STA cell_x ; ...is the cell to test | |||||||
| 1CCE | LDA hero_door_y,x ; ...and its y... | |||||||
| 1CD1 | STA cell_y ; ...is the cell's y | |||||||
| 1CD4 | TXA ; Keep the hero's number... | |||||||
| 1CD5 | PHA ; ...on the stack for the key check | |||||||
| 1CD6 | LDX #max_door ; Doors 20 to 1: is one in that cell? | |||||||
| 1CD8 | .check_door←1← 1DB5 JMP | |||||||
| LDA door_x,x ; This door's x (&FF once opened)... | ||||||||
| 1CDB | CMP cell_x ; ...the cell being tested? | |||||||
| 1CDE | BEQ check_door_cell_y ; Yes: check its y | |||||||
| 1CE0 | JMP next_door ; No: next door | |||||||
| 1CE3 | .check_door_cell_y←1← 1CDE BEQ | |||||||
| LDA door_y,x ; This door's y (&FF once opened)... | ||||||||
| 1CE6 | CMP cell_y ; ...the cell being tested? | |||||||
| 1CE9 | BEQ check_door_key ; Yes: the hero has walked into this door | |||||||
| 1CEB | JMP next_door ; No: next door | |||||||
| 1CEE | .check_door_key←1← 1CE9 BEQ | |||||||
| PLA ; Does the hero carry this door's key? | ||||||||
| 1CEF | TAY ; Y = the hero's number... | |||||||
| 1CF0 | PHA ; ...kept on the stack | |||||||
| 1CF1 | TXA ; A = the door's number: key n opens door n | |||||||
| 1CF2 | CMP hero_key,y ; Is it the number of the key the hero carries? | |||||||
| 1CF5 | BEQ open_door ; Yes: open door | |||||||
| 1CF7 | JMP next_door ; No key, or the wrong one: the door stays shut | |||||||
| ; The hero has the key: score 7, sound the door, erase it, clear ; its wall bit, and use up the key. | ||||||||
| 1CFA | .open_door←1← 1CF5 BEQ | |||||||
| TXA ; Open the door: 7 points... | ||||||||
| 1CFB | PHA ; Keep the door's number... | |||||||
| 1CFC | TYA ; ...and the hero's... | |||||||
| 1CFD | PHA ; ...on the stack | |||||||
| 1CFE | LDY #7 ; Seven points, one per add_point call | |||||||
| 1D00 | LDX scratch ; ...X = the hero who opened the door, for add_point | |||||||
| 1D03 | .door_points_loop←1← 1D0B BNE | |||||||
| TYA ; Keep the count of points still to give | ||||||||
| 1D04 | PHA ; ...on the stack, as add_point uses Y | |||||||
| 1D05 | JSR add_point ; One point to the hero's score, redrawn | |||||||
| 1D08 | PLA ; Recover the count of points to give | |||||||
| 1D09 | TAY ; ...back into Y | |||||||
| 1D0A | DEY ; One fewer to give | |||||||
| 1D0B | BNE door_points_loop ; More to give: add the next point | |||||||
| ; The door sound: food_sound played at a lower pitch. | ||||||||
| 1D0D | LDA #&96 ; The door sound is the food sound, lower... | |||||||
| 1D0F | STA food_sound + 4 ; ...pitch 150 instead of food's 200 | |||||||
| 1D12 | LDX #<(food_sound) ; SOUND food_sound: block address low... | |||||||
| 1D14 | LDY #>(food_sound) ; ...and high: the door sound's block | |||||||
| 1D16 | LDA #osword_sound ; OSWORD 7: SOUND | |||||||
| 1D18 | JSR osword ; Sound the door opening SOUND command | |||||||
| 1D1B | LDA #&c8 ; ...then put food's pitch back... | |||||||
| 1D1D | STA food_sound + 4 ; ...to 200, for the next food eaten | |||||||
| ; Erase the door from every view showing it, keeping its cell in ; monster_x + 35 and monster_y + 35 across plot_at_cell, which ; overwrites cell_x and cell_y. | ||||||||
| 1D20 | LDA cell_y ; Save the door's cell; plot_at_cell changes cell_x/y... | |||||||
| 1D23 | STA monster_y + 35 ; ...y into the spare byte at monster_y + 35... | |||||||
| 1D26 | LDA cell_x ; ...then the door's x... | |||||||
| 1D29 | STA monster_x + 35 ; ...into the spare byte at monster_x + 35 | |||||||
| 1D2C | LDA #spr_blank ; Erase the door from the screen... | |||||||
| 1D2E | STA sprite_number ; ...the blank as the sprite to plot | |||||||
| 1D30 | LDA #0 ; ...squarely on the door's cell... | |||||||
| 1D32 | STA plot_offset_x ; ...no shift across (plot_offset_x 0)... | |||||||
| 1D34 | STA plot_offset_y ; ...or down (plot_offset_y 0) | |||||||
| 1D36 | JSR plot_at_cell ; Blank the door in every view showing its room | |||||||
| 1D39 | LDA monster_x + 35 ; ...and recover its cell | |||||||
| 1D3C | STA cell_x ; ...back into cell_x... | |||||||
| 1D3F | LDA monster_y + 35 ; ...then the door's y... | |||||||
| 1D42 | STA cell_y ; ...back into cell_y | |||||||
| 1D45 | PLA ; Recover the hero number pushed at open_door... | |||||||
| 1D46 | TAY ; ...into Y, unused: Y is the wall row index below | |||||||
| 1D47 | PLA ; Recover the door number... | |||||||
| 1D48 | TAX ; ...into X, to remove its entry once the wall is gone | |||||||
| ; Clear the door's bit in room_walls, so test_wall no longer ; stops heroes, monsters or missiles there. | ||||||||
| 1D49 | LDA cell_y ; Door's room: (y AND &F8) x 4 + (x AND &F8)... | |||||||
| 1D4C | AND #&f8 ; ...y AND &F8: the room's top row, 8 rows a room... | |||||||
| 1D4E | STA scratch ; ...kept in scratch to add three more times | |||||||
| 1D51 | CLC ; ...clear carry for the adds | |||||||
| 1D52 | ADC scratch ; ...x 2... | |||||||
| 1D55 | ADC scratch ; ...x 3... | |||||||
| 1D58 | ADC scratch ; ...x 4: 32 bytes per row of four rooms | |||||||
| 1D5B | STA map_ptr ; ...kept in map_ptr | |||||||
| 1D5D | LDA cell_x ; ...plus the room column... | |||||||
| 1D60 | AND #&f8 ; ...x AND &F8: 8 bytes per room... | |||||||
| 1D62 | ADC map_ptr ; ...added to the row of rooms' offset... | |||||||
| 1D64 | STA map_ptr ; ...giving the room's offset in room_walls | |||||||
| 1D66 | LDA #>(room_walls) ; ...plus room_walls' page... | |||||||
| 1D68 | STA map_ptr_hi ; ...in map_ptr_hi: map_ptr points at the room | |||||||
| 1D6A | TXA ; Keep the door number... | |||||||
| 1D6B | PHA ; ...on the stack while X is used for the bit | |||||||
| 1D6C | LDA cell_x ; ...mask for the column... | |||||||
| 1D6F | AND #7 ; ...x AND 7, the cell's column in the room... | |||||||
| 1D71 | TAX ; ...as the index into bit_masks... | |||||||
| 1D72 | LDA bit_masks,x ; ...for the cell's bit in its row byte... | |||||||
| 1D75 | EOR #&ff ; ...inverted, to keep every other wall... | |||||||
| 1D77 | STA scratch ; ...as the mask to clear it with | |||||||
| 1D7A | LDA cell_y ; ...byte for the row... | |||||||
| 1D7D | AND #7 ; ...y AND 7, the cell's row in the room... | |||||||
| 1D7F | TAY ; ...indexes the room's eight row bytes | |||||||
| 1D80 | LDA (map_ptr),y ; ...the row of walls holding the door... | |||||||
| 1D82 | AND scratch ; ...knock out the door's bit... | |||||||
| 1D85 | STA (map_ptr),y ; ...so the doorway no longer blocks anyone | |||||||
| 1D87 | PLA ; Recover the door number... | |||||||
| 1D88 | TAX ; ...into X, to index door_x and door_y | |||||||
| ; Remove the door from door_x/door_y and use up the key, erasing ; its icon from the hero's panel. | ||||||||
| 1D89 | LDA #off_map ; Take the door out of the level... | |||||||
| 1D8B | STA door_x,x ; ...x off the map: no hero matches it again... | |||||||
| 1D8E | STA door_y,x ; ...and y off the map | |||||||
| 1D91 | PLA ; Recover the hero number pushed at check_doors... | |||||||
| 1D92 | TAX ; ...into X, for their key slot and panel | |||||||
| 1D93 | LDA #0 ; The key is used up: the hero carries none | |||||||
| 1D95 | STA hero_key,x ; ...in the hero's key slot | |||||||
| 1D98 | LDA #spr_blank_key_icon ; Erase the key icon from the hero's panel | |||||||
| 1D9A | STA sprite_number ; ...as the sprite to plot | |||||||
| 1D9C | LDA hero_panel_y,x ; ...from the hero's panel row... | |||||||
| 1D9F | SEC ; ...set carry to subtract | |||||||
| 1DA0 | SBC #&0d ; ...less 13: the key icon's row... | |||||||
| 1DA2 | STA plot_y ; ...as plot_y, the icon's screen row | |||||||
| 1DA4 | LDA #panel_left + 5 ; ...in panel column panel_left + 5... | |||||||
| 1DA6 | STA plot_x ; ...as plot_x, the icon's column | |||||||
| 1DA8 | TXA ; Keep the hero number... | |||||||
| 1DA9 | PHA ; ...on the stack across plot_sprite | |||||||
| 1DAA | JSR plot_sprite ; Plot the blank icon over the key icon | |||||||
| 1DAD | PLA ; Recover the hero number... | |||||||
| 1DAE | TAX ; ...into X, for next_hero_doors | |||||||
| 1DAF | JMP next_hero_doors ; One door a frame per hero: on to the next hero | |||||||
| 1DB2 | .next_door←3← 1CE0 JMP← 1CEB JMP← 1CF7 JMP | |||||||
| DEX ; Next door down, 20 to 1 | ||||||||
| 1DB3 | BEQ doors_done ; Doors all checked: this hero is done | |||||||
| 1DB5 | JMP check_door ; Otherwise check the next door | |||||||
| 1DB8 | .doors_done←1← 1DB3 BEQ | |||||||
| PLA ; Recover the hero number pushed at check_doors... | ||||||||
| 1DB9 | TAX ; ...into X, to move on from this hero | |||||||
| 1DBA | .next_hero_doors←1← 1DAF JMP | |||||||
| INX ; Next hero, 0 to 3 | ||||||||
| 1DBB | CPX #4 ; All four heroes done? | |||||||
| 1DBD | BEQ draw_keys ; Yes: on to the keys | |||||||
| 1DBF | JMP check_doors ; No: check this hero against the doors | |||||||
| ; Keys. Redraw the keys on the floor, then for each hero: drop a ; dead hero's key where they fell, or pick up the key at the ; hero's cell, leaving any key carried in its place. The swap ; flag only skips the frame after a swap, so a hero who stays on ; the cell swaps back on the frame after that. The heroes were ; drawn earlier in the frame, so a key under a hero is drawn ; over them. | ||||||||
| 1DC2 | .draw_keys←1← 1DBD BEQ | |||||||
| LDA #0 ; Redraw every key lying on the floor, 20 to 1 | ||||||||
| 1DC4 | STA plot_offset_x ; ...on their cells: no pixel offset... | |||||||
| 1DC6 | STA plot_offset_y ; ...across or down: keys sit squarely in cells | |||||||
| 1DC8 | LDA #spr_key ; ...in the key sprite... | |||||||
| 1DCA | STA sprite_number ; ...as the sprite to plot | |||||||
| 1DCC | LDX #max_key ; ...counting keys down from 20; entry 0 is never drawn | |||||||
| 1DCE | .draw_each_key←1← 1DE2 BNE | |||||||
| LDA key_x,x ; The key's x... | ||||||||
| 1DD1 | STA cell_x ; ...is the column to plot at... | |||||||
| 1DD4 | LDA key_y,x ; ...and y (off the map if it is carried)... | |||||||
| 1DD7 | STA cell_y ; ...the row: plot_at_cell needs both each time | |||||||
| 1DDA | TXA ; Keep the key number... | |||||||
| 1DDB | PHA ; ...on the stack across plot_at_cell | |||||||
| 1DDC | JSR plot_at_cell ; Plot it in every view showing its cell | |||||||
| 1DDF | PLA ; Recover the key number... | |||||||
| 1DE0 | TAX ; ...into X, counting down the keys | |||||||
| 1DE1 | DEX ; Next key down | |||||||
| 1DE2 | BNE draw_each_key ; More keys: draw the next | |||||||
| 1DE4 | LDX #0 ; For each hero, from hero 0... | |||||||
| 1DE6 | .check_hero_keys←1← 1ECB JMP | |||||||
| LDA hero_direction,x ; Still in play (a direction set)? | ||||||||
| 1DE9 | BNE check_key_swap ; Yes: look for a key to pick up | |||||||
| 1DEB | LDA hero_key,x ; Out of play: dead, dying or gone. Holding a key? | |||||||
| 1DEE | BNE check_death_finished ; Yes: see whether the death has played out | |||||||
| 1DF0 | JMP next_hero_keys ; No key: nothing to do for this hero | |||||||
| 1DF3 | .check_death_finished←1← 1DEE BNE | |||||||
| LDA hero_frame,x ; Has the death animation reached its end? | ||||||||
| 1DF6 | CMP #8 ; ...frame 8 is the last of the death | |||||||
| 1DF8 | BNE check_key_swap ; Still dying: key checks go on as if in play | |||||||
| ; A dead hero's death animation has ended: leave their key on ; the cell where they fell and erase its icon. | ||||||||
| 1DFA | LDY hero_key,x ; Yes: drop the key where the hero fell | |||||||
| 1DFD | LDA hero_x,x ; ...at the hero's x... | |||||||
| 1E00 | STA key_x,y ; ...as the key's x... | |||||||
| 1E03 | LDA hero_y,x ; ...and the hero's y... | |||||||
| 1E06 | STA key_y,y ; ...as the key's y | |||||||
| 1E09 | LDA #0 ; The dead hero carries no key now... | |||||||
| 1E0B | STA hero_key,x ; ...so this is done only once | |||||||
| 1E0E | LDA #spr_blank_key_icon ; Erase the key icon from the hero's panel | |||||||
| 1E10 | STA sprite_number ; ...as the sprite to plot | |||||||
| 1E12 | LDA hero_panel_y,x ; ...using the hero's panel row... | |||||||
| 1E15 | SEC ; ...set carry to subtract | |||||||
| 1E16 | SBC #&0d ; ...less 13: the key icon's row... | |||||||
| 1E18 | STA plot_y ; ...as plot_y, the icon's screen row | |||||||
| 1E1A | LDA #panel_left + 5 ; ...in panel column panel_left + 5... | |||||||
| 1E1C | STA plot_x ; ...as plot_x, the icon's column | |||||||
| 1E1E | TXA ; Keep the hero number... | |||||||
| 1E1F | PHA ; ...on the stack across plot_sprite | |||||||
| 1E20 | JSR plot_sprite ; Plot the blank icon over the key icon | |||||||
| 1E23 | PLA ; Recover the hero number... | |||||||
| 1E24 | TAX ; ...into X, for next_hero_keys | |||||||
| 1E25 | JMP next_hero_keys ; Key dropped: on to the next hero | |||||||
| 1E28 | .check_key_swap←2← 1DE9 BNE← 1DF8 BNE | |||||||
| LDA hero_key_dropped,x ; Swapped keys on the last frame? | ||||||||
| 1E2B | BEQ check_key_cell ; No: look for a key at the hero's cell | |||||||
| 1E2D | LDA #0 ; Yes: skip this frame, clearing the flag | |||||||
| 1E2F | STA hero_key_dropped,x ; ...so next frame's check may swap again | |||||||
| 1E32 | JMP next_hero_keys ; ...and move on to the next hero | |||||||
| ; Look for a key at the hero's cell, keys 20 to 1; the first ; found is picked up. | ||||||||
| 1E35 | .check_key_cell←1← 1E2B BEQ | |||||||
| LDA hero_x,x ; Is there a key at the hero's cell? Its x... | ||||||||
| 1E38 | STA cell_x ; ...in cell_x, for each key's x to match... | |||||||
| 1E3B | LDA hero_y,x ; ...and the hero's y... | |||||||
| 1E3E | STA cell_y ; ...in cell_y, for each key's y | |||||||
| 1E41 | TXA ; Keep the hero number... | |||||||
| 1E42 | PHA ; ...on the stack while X counts the keys | |||||||
| 1E43 | LDX #max_key ; ...keys 20 to 1; entry 0 is never picked up | |||||||
| 1E45 | .check_key←1← 1EC1 JMP | |||||||
| LDA key_x,x ; This key's x... | ||||||||
| 1E48 | CMP cell_x ; ...at the hero's x? | |||||||
| 1E4B | BNE next_key ; No: try the next key | |||||||
| 1E4D | LDA key_y,x ; ...and its y... | |||||||
| 1E50 | CMP cell_y ; ...at the hero's y? | |||||||
| 1E53 | BNE next_key ; No: try the next key | |||||||
| 1E55 | LDA #spr_blank ; Yes: pick it up, erasing it from the floor | |||||||
| 1E57 | STA sprite_number ; ...as the sprite to plot... | |||||||
| 1E59 | LDA #0 ; ...squarely on the key's cell... | |||||||
| 1E5B | STA plot_offset_x ; ...no shift across (plot_offset_x 0)... | |||||||
| 1E5D | STA plot_offset_y ; ...or down (plot_offset_y 0) | |||||||
| 1E5F | TXA ; Keep the key number... | |||||||
| 1E60 | PHA ; ...on the stack across plot_at_cell | |||||||
| 1E61 | JSR plot_at_cell ; Blank the key in every view showing it | |||||||
| 1E64 | PLA ; Recover the key number... | |||||||
| 1E65 | TAX ; ...into X: the key being picked up | |||||||
| 1E66 | PLA ; Show the key icon in the hero's panel: hero... | |||||||
| 1E67 | TAY ; ...into Y, to index hero_panel_y... | |||||||
| 1E68 | PHA ; ...and back on the stack for later | |||||||
| 1E69 | LDA #spr_key_icon ; ...in the key icon sprite... | |||||||
| 1E6B | STA sprite_number ; ...as the sprite to plot | |||||||
| 1E6D | LDA hero_panel_y,y ; ...from the hero's panel row... | |||||||
| 1E70 | SEC ; ...set carry to subtract | |||||||
| 1E71 | SBC #&0d ; ...less 13: the key icon's row... | |||||||
| 1E73 | STA plot_y ; ...as plot_y, the icon's screen row | |||||||
| 1E75 | LDA #panel_left + 5 ; ...in panel column panel_left + 5... | |||||||
| 1E77 | STA plot_x ; ...as plot_x, the icon's column | |||||||
| 1E79 | TYA ; Keep the hero number... | |||||||
| 1E7A | PHA ; ...on the stack... | |||||||
| 1E7B | TXA ; ...and the key number... | |||||||
| 1E7C | PHA ; ...both kept across plot_sprite | |||||||
| 1E7D | JSR plot_sprite ; Plot the key icon | |||||||
| 1E80 | PLA ; Recover the key number... | |||||||
| 1E81 | TAX ; ...into X: the key to carry... | |||||||
| 1E82 | PLA ; ...and the hero number... | |||||||
| 1E83 | TAY ; ...into Y: the hero picking it up | |||||||
| ; The swap: the key carried (or unused entry 0) goes on the ; floor here, the new one is carried and taken off the map, and ; hero_key_dropped makes the next frame pass this hero by. | ||||||||
| 1E84 | TXA ; Drop the key carried (if any) in this cell... | |||||||
| 1E85 | PHA ; ...keeping the new key's number on the stack... | |||||||
| 1E86 | LDX hero_key,y ; ...the old key, or unseen entry 0 if none... | |||||||
| 1E89 | LDA hero_x,y ; ...goes to the hero's x... | |||||||
| 1E8C | STA key_x,x ; ...as its x... | |||||||
| 1E8F | LDA hero_y,y ; ...and the hero's y... | |||||||
| 1E92 | STA key_y,x ; ...as its y | |||||||
| 1E95 | PLA ; Recover the new key's number... | |||||||
| 1E96 | TAX ; ...into X, and in A to carry | |||||||
| 1E97 | STA hero_key,y ; ...and carry the new one | |||||||
| 1E9A | LDA #1 ; Mark the swap | |||||||
| 1E9C | STA hero_key_dropped,y ; ...so the dropped key is left alone next frame | |||||||
| 1E9F | LDA #off_map ; Take the new key off the floor | |||||||
| 1EA1 | STA key_x,x ; ...x off the map, so draw_keys skips it... | |||||||
| 1EA4 | STA key_y,x ; ...and y off the map | |||||||
| 1EA7 | LDX #<(key_envelope) ; Sound the pickup: ENVELOPE key_envelope low... | |||||||
| 1EA9 | LDY #>(key_envelope) ; ...and high: the pickup's envelope block | |||||||
| 1EAB | LDA #osword_envelope ; OSWORD 8: ENVELOPE | |||||||
| 1EAD | JSR osword ; Define the key pickup envelope ENVELOPE command | |||||||
| 1EB0 | LDX #<(key_sound) ; SOUND key_sound: block address low... | |||||||
| 1EB2 | LDY #>(key_sound) ; ...and high: the pickup's sound block | |||||||
| 1EB4 | LDA #osword_sound ; OSWORD 7: SOUND | |||||||
| 1EB6 | JSR osword ; Play the key pickup sound SOUND command | |||||||
| 1EB9 | PLA ; Recover the hero number... | |||||||
| 1EBA | TAX ; ...into X, for next_hero_keys | |||||||
| 1EBB | JMP next_hero_keys ; One key a frame per hero: next hero | |||||||
| 1EBE | .next_key←2← 1E4B BNE← 1E53 BNE | |||||||
| DEX ; Next key down, 20 to 1 | ||||||||
| 1EBF | BEQ keys_done ; Keys all checked: this hero is done | |||||||
| 1EC1 | JMP check_key ; Otherwise check the next key | |||||||
| 1EC4 | .keys_done←1← 1EBF BEQ | |||||||
| PLA ; Recover the hero number pushed at check_key_cell... | ||||||||
| 1EC5 | TAX ; ...into X, to move on from this hero | |||||||
| 1EC6 | .next_hero_keys←4← 1DF0 JMP← 1E25 JMP← 1E32 JMP← 1EBB JMP | |||||||
| INX ; Next hero, 0 to 3 | ||||||||
| 1EC7 | CPX #4 ; All four heroes done? | |||||||
| 1EC9 | BEQ update_rest ; Yes: on with the rest of the frame | |||||||
| 1ECB | JMP check_hero_keys ; No: check this hero's keys | |||||||
| ; The rest of the frame: objects, missiles, monsters, then the ; pause key. | ||||||||
| 1ECE | .update_rest←1← 1EC9 BEQ | |||||||
| JSR draw_objects ; Draw the objects over the floor | ||||||||
| 1ED1 | JSR move_missiles ; Move the missiles a cell each | |||||||
| 1ED4 | JSR update_monsters ; Move the monsters | |||||||
| ; The pause key, f1, last in each frame's update. OSBYTE &7A ; reports only the lowest-numbered key held, so f1 is missed ; while a key numbered below &71 is held with it. Paused, the ; game waits here for f1 to be released, pressed again and ; released again. os_vsync_counter is not set again afterwards: ; the MOS goes on counting it down through the pause, and as a ; single byte it can wrap round to a positive value, which makes ; play_level wait up to 128 more vsyncs (about 2.6 seconds) ; before the next frame. | ||||||||
| 1ED7 | LDA #osbyte_scan_keyboard_from_16 ; Pause key: OSBYTE &7A, lowest-numbered key held | |||||||
| 1ED9 | JSR osbyte ; X = its internal number, or &FF if none. Scan keyboard from key 16 | |||||||
| 1EDC | CPX #&71 ; f1 (&71)? A held key numbered below &71 hides it | |||||||
| 1EDE | BNE not_paused ; No: the frame is over | |||||||
| 1EE0 | .wait_pause_release←1← 1EE5 BEQ | |||||||
| JSR osbyte ; Paused, the game frozen: wait for f1 to go up... Scan keyboard from key 16 | ||||||||
| 1EE3 | CPX #&71 ; ...is f1 still held? | |||||||
| 1EE5 | BEQ wait_pause_release ; Yes: keep waiting for its release | |||||||
| 1EE7 | .wait_pause_press←1← 1EEC BNE | |||||||
| JSR osbyte ; ...then for f1 to be pressed again... Scan keyboard from key 16 | ||||||||
| 1EEA | CPX #&71 ; ...is it f1? | |||||||
| 1EEC | BNE wait_pause_press ; No: stay paused | |||||||
| 1EEE | .wait_pause_release_again←1← 1EF3 BEQ | |||||||
| JSR osbyte ; ...and released, so it does not pause again Scan keyboard from key 16 | ||||||||
| 1EF1 | CPX #&71 ; ...is f1 still held? | |||||||
| 1EF3 | BEQ wait_pause_release_again ; Yes: keep waiting, then play on | |||||||
| 1EF5 | .not_paused←1← 1EDE BNE | |||||||
| RTS ; Return to play_level | ||||||||
UnusedZero bytes, which nothing reads. |
|
| 1EF6 | EQUB &00, &00, &00, &00, &00, &00 ; Zeros |
UnusedFour &3C bytes, "<<<<", which nothing reads. |
|
| 1EFC | EQUS "<<<<" ; Not referenced |
Play a level until it endsThe game's frame loop: play the current level until it is over. Called once per level by new_game's level loop, after the level is drawn, the status panel set up and absent heroes removed; when it returns, new_game gives each dead hero their starting attributes back, ending the game if all four died. A frame, in order:
How the level ends: hero_enters_exit is entered with JSR but leaves with a JMP to play_level, so each descent leaves a return address (into check_exit at &1F8E) on the stack. The RTS at the level's end therefore returns into check_exit once for each hero who left by the exit; each such return runs one more full frame before the next RTS, and only the last returns to new_game.
|
||||||||
| ; Pace the game: start a frame every three vsyncs. | ||||||||
| 1F00 | .play_level←7← 0E65 JSR← 1F03 BPL← 1F9B JMP← 1FEF JMP← 2023 JMP← 2037 JMP← 208E JMP | |||||||
| LDA os_vsync_counter ; Wait for the vertical sync counter to pass zero... | ||||||||
| 1F03 | BPL play_level ; Not yet negative: keep waiting | |||||||
| 1F05 | LDA #2 ; ...and set it for three syncs from now | |||||||
| 1F07 | STA os_vsync_counter ; ...in the MOS's vertical sync counter | |||||||
| ; This frame's play: the Chalice on level 25, then all but the ; exit (update_game). | ||||||||
| 1F0A | JSR check_for_victory ; On level 25: has a hero reached the Chalice? | |||||||
| 1F0D | JSR update_game ; Run a frame: heroes, keys, objects, monsters | |||||||
| ; Is the level over? Never while a hero is going down the exit; ; otherwise when every hero is out of play and no death ; animation is still running. | ||||||||
| 1F10 | LDA exit_busy ; A hero going down the exit? | |||||||
| 1F13 | BNE check_exit ; Yes: the level goes on | |||||||
| 1F15 | LDX #4 ; Is any hero in play, or still dying? Heroes 3 to 0 | |||||||
| 1F17 | .count_heroes_in_play←1← 1F2B BNE | |||||||
| LDA hero_direction - 1,x ; In play (a direction set)? | ||||||||
| 1F1A | BNE check_exit ; Yes: the level goes on | |||||||
| 1F1C | LDA hero_health_tens - 1,x ; Out of play: dead... | |||||||
| 1F1F | CMP #spr_digit_0 - 1 ; ...(health tens digit below 0)... | |||||||
| 1F21 | BNE next_hero_in_play ; No: alive but out of play; next hero | |||||||
| 1F23 | LDA hero_frame - 1,x ; ...with the death animation unfinished? | |||||||
| 1F26 | CMP #8 ; ...frame 8 is the last of the death | |||||||
| 1F28 | BCC check_exit ; Yes: the level goes on | |||||||
| 1F2A | .next_hero_in_play←1← 1F21 BNE | |||||||
| DEX ; Next hero down (X is the hero + 1) | ||||||||
| 1F2B | BNE count_heroes_in_play ; More heroes: check the next | |||||||
| 1F2D | LDX shrunk_hero ; The level is over: restore the last exiting hero's sprites | |||||||
| 1F30 | BMI play_level_done ; None (&FF): nothing to restore | |||||||
| 1F32 | JSR restore_hero_sprites ; Give them back their full-size sprites | |||||||
| 1F35 | .play_level_done←1← 1F30 BMI | |||||||
| RTS ; Return, perhaps into this loop at &1F8E | ||||||||
| ; Look for a hero on the exit. The first found leaves their key ; beside it, leaves play and the map, and starts down; the exit ; is hidden off the map until they have gone. | ||||||||
| 1F36 | .check_exit←3← 1F13 BNE← 1F1A BNE← 1F28 BCC | |||||||
| LDX #0 ; Is a hero on the exit? From hero 0 | ||||||||
| 1F38 | .check_hero_on_exit←1← 1F94 BNE | |||||||
| LDA hero_x,x ; The hero's x... | ||||||||
| 1F3B | CMP exit_x ; ...at the exit's x? | |||||||
| 1F3E | BNE next_hero_exit ; No: next hero | |||||||
| 1F40 | LDA hero_y,x ; ...and the hero's y... | |||||||
| 1F43 | CMP exit_y ; ...at the exit's y? | |||||||
| 1F46 | BNE next_hero_exit ; No: next hero | |||||||
| 1F48 | JSR drop_key ; Yes: drop their key beside it | |||||||
| 1F4B | LDA #step_out_of_play ; Take them out of play for the rest of the level | |||||||
| 1F4D | STA hero_step,x ; ...so they are never animated... | |||||||
| 1F50 | LDA #0 ; ...and no direction... | |||||||
| 1F52 | STA hero_direction,x ; ...so move_heroes skips them | |||||||
| 1F55 | LDA hero_x,x ; Erase them from the exit's cell | |||||||
| 1F58 | STA cell_x ; ...is the cell to blank: x... | |||||||
| 1F5B | LDA hero_y,x ; ...and the hero's y... | |||||||
| 1F5E | STA cell_y ; ...and y... | |||||||
| 1F61 | LDA #0 ; ...squarely on the cell... | |||||||
| 1F63 | STA plot_offset_x ; ...no shift across (plot_offset_x 0)... | |||||||
| 1F65 | STA plot_offset_y ; ...or down (plot_offset_y 0)... | |||||||
| 1F67 | LDA #spr_blank ; ...with the blank sprite | |||||||
| 1F69 | STA sprite_number ; ...as the sprite to plot | |||||||
| 1F6B | TXA ; Keep the hero number... | |||||||
| 1F6C | PHA ; ...on the stack across plot_at_cell | |||||||
| 1F6D | JSR plot_at_cell ; Plot the blank in every view showing them | |||||||
| 1F70 | PLA ; Recover the hero number... | |||||||
| 1F71 | TAX ; ...into X, to move them off the map | |||||||
| 1F72 | LDA #off_map ; Move them off the map | |||||||
| 1F74 | STA hero_x,x ; ...x off the map, so nothing meets them | |||||||
| 1F77 | LDA exit_x ; Hide the exit while they go down it, keeping its position | |||||||
| 1F7A | STA exit_saved_x ; ...x in exit_saved_x, for redraw_exit... | |||||||
| 1F7D | LDA exit_y ; ...and its y... | |||||||
| 1F80 | STA exit_saved_y ; ...in exit_saved_y, for restore_exit too | |||||||
| 1F83 | LDA #off_map ; ...then put the exit off the map... | |||||||
| 1F85 | STA exit_x ; ...x &FF... | |||||||
| 1F88 | STA exit_y ; ...and y &FF, so no other hero can enter it | |||||||
| 1F8B | JSR hero_enters_exit ; Start the exit animation (which jumps back to play_level) | |||||||
| 1F8E | JMP check_exit_busy ; Reached by the RTS at the end of the level: one more frame | |||||||
| 1F91 | .next_hero_exit←2← 1F3E BNE← 1F46 BNE | |||||||
| INX ; Next hero, 0 to 3 | ||||||||
| 1F92 | CPX #4 ; All four heroes checked? | |||||||
| 1F94 | BNE check_hero_on_exit ; No: check the next | |||||||
| ; The descent, one step a frame while exit_busy is set: redraw ; the exit, then the hero on it a quarter turn on, at the size ; and offsets for this turn. | ||||||||
| 1F96 | .check_exit_busy←1← 1F8E JMP | |||||||
| LDA exit_busy ; A hero going down the exit? | ||||||||
| 1F99 | BNE redraw_exit ; Yes: draw this frame of the descent | |||||||
| 1F9B | JMP play_level ; No: next frame | |||||||
| 1F9E | .redraw_exit←1← 1F99 BNE | |||||||
| LDX exiting_hero ; Redraw the exit under the spinning hero | ||||||||
| 1FA1 | LDA #0 ; ...squarely on its cell... | |||||||
| 1FA3 | STA plot_offset_x ; ...no shift across (plot_offset_x 0)... | |||||||
| 1FA5 | STA plot_offset_y ; ...or down (plot_offset_y 0)... | |||||||
| 1FA7 | LDA exit_saved_x ; ...at exit_saved_x... | |||||||
| 1FAA | STA cell_x ; ...(exit_x itself is off the map)... | |||||||
| 1FAD | LDA exit_saved_y ; ...and exit_saved_y... | |||||||
| 1FB0 | STA cell_y ; ...as the cell to plot... | |||||||
| 1FB3 | LDA #spr_exit ; ...with the exit sprite... | |||||||
| 1FB5 | STA sprite_number ; ...as the sprite to plot | |||||||
| 1FB7 | JSR plot_at_cell ; Plot it in every view showing it | |||||||
| 1FBA | LDX exiting_hero ; Turn the hero a quarter: up, right, down, left | |||||||
| 1FBD | CLC ; ...clear carry for the add | |||||||
| 1FBE | LDA exit_spin ; ...from the current direction... | |||||||
| 1FC1 | ADC #2 ; ...two sprites on: the next direction... | |||||||
| 1FC3 | STA exit_spin ; ...kept for the next frame | |||||||
| 1FC6 | CMP #9 ; Past left (9): a full turn? | |||||||
| 1FC8 | BEQ next_turn ; Yes: shrink the hero, showing just the exit | |||||||
| 1FCA | CLC ; Plot the hero on the exit, centred for its current size | |||||||
| 1FCB | LDA hero_sprites,x ; ...the hero's sprite base... | |||||||
| 1FCE | ADC exit_spin ; ...plus the direction's frame... | |||||||
| 1FD1 | STA sprite_number ; ...as the sprite to plot | |||||||
| 1FD3 | LDA exit_saved_x ; ...on the exit's cell: its x... | |||||||
| 1FD6 | STA cell_x ; ...set again, as plot_at_cell changed cell_x... | |||||||
| 1FD9 | LDA exit_saved_y ; ...and its y... | |||||||
| 1FDC | STA cell_y ; ...and cell_y | |||||||
| 1FDF | LDX exit_shrinks_left ; ...with offsets for its size, by turns left... | |||||||
| 1FE2 | LDA exit_offsets_x,x ; ...byte columns right, from exit_offsets_x... | |||||||
| 1FE5 | STA plot_offset_x ; ...as plot_offset_x, centring the narrower sprite... | |||||||
| 1FE7 | LDA exit_offsets_y,x ; ...pixel rows down, from exit_offsets_y... | |||||||
| 1FEA | STA plot_offset_y ; ...as plot_offset_y, centring the shorter one | |||||||
| 1FEC | JSR plot_at_cell ; Plot the hero in every view showing the exit | |||||||
| 1FEF | JMP play_level ; Next frame: the next quarter turn | |||||||
| ; A full turn is done. After the fourth the hero has gone; after ; each of the first three, sprites base + 1 to base + 7 shrink ; by a byte and three rows. | ||||||||
| 1FF2 | .next_turn←1← 1FC8 BEQ | |||||||
| LDA #&ff ; Start the next turn from facing up | ||||||||
| 1FF4 | STA exit_spin ; ...-1, so the next frame's +2 gives 1 | |||||||
| 1FF7 | DEC exit_shrinks_left ; Fourth turn done? | |||||||
| 1FFA | BEQ restore_exit ; Yes: the hero has gone; bring the exit back | |||||||
| 1FFC | CLC ; Shrink sprites base + 1 to + 7: a byte narrower... | |||||||
| 1FFD | LDA hero_sprites,x ; ...the hero's sprite base... | |||||||
| 2000 | ADC #1 ; ...+1: their first sprite... | |||||||
| 2002 | TAY ; ...in Y, for the height loop... | |||||||
| 2003 | TAX ; ...and in X, for the width loop | |||||||
| 2004 | ADC #7 ; ...+7: stop before base + 8, left frame 1 | |||||||
| 2006 | STA scratch ; ...kept as the end | |||||||
| 2009 | .shrink_hero_width←1← 2010 BNE | |||||||
| DEC sprite_widths,x ; One byte (two pixels) narrower | ||||||||
| 200C | INX ; Next of the hero's seven sprites | |||||||
| 200D | CPX scratch ; Reached the end? | |||||||
| 2010 | BNE shrink_hero_width ; No: narrow the next | |||||||
| 2012 | TYA ; Three rows shorter... | |||||||
| 2013 | TAX ; ...from the first sprite again | |||||||
| 2014 | .shrink_hero_height←1← 2021 BNE | |||||||
| SEC ; ...set carry to subtract | ||||||||
| 2015 | LDA sprite_heights,x ; This sprite's height... | |||||||
| 2018 | SBC #3 ; ...less three rows... | |||||||
| 201A | STA sprite_heights,x ; ...stored back in sprite_heights | |||||||
| 201D | INX ; Next of the hero's seven sprites | |||||||
| 201E | CPX scratch ; Reached the end? | |||||||
| 2021 | BNE shrink_hero_height ; No: shorten the next | |||||||
| 2023 | JMP play_level ; ...three rows shorter. Next frame | |||||||
| ; The hero has gone: put the exit back. | ||||||||
| 2026 | .restore_exit←1← 1FFA BEQ | |||||||
| LDA exit_saved_x ; Put the exit back where it was... | ||||||||
| 2029 | STA exit_x ; ...exit_saved_x back as its x... | |||||||
| 202C | LDA exit_saved_y ; ...and its saved y... | |||||||
| 202F | STA exit_y ; ...as its y, so the next hero can use it | |||||||
| 2032 | LDA #0 ; ...and end the animation | |||||||
| 2034 | STA exit_busy ; ...exit no longer busy | |||||||
| 2037 | JMP play_level ; Next frame: the descent is over | |||||||
Start a hero going down the exitStart hero X's descent: the hero spins on the exit for four turns, shrinking after each of the first three. Called by play_level's check_exit for a hero who has just stepped onto the exit, after drop_key, and after the hero has been taken out of play and the exit hidden off the map. queue_exit_marker plays the exit sound and puts a nobody_returns marker in returning_hero_queue, as remove_absent_heroes does for a hero nobody plays. Any hero shrunk on an earlier descent (shrunk_hero) gets their full-size sprites back, as the sprites are shared with no copy. Then exit_busy is set, exiting_hero and shrunk_hero become X, exit_spin starts at -1 (the first frame's +2 gives the up-facing sprite) and exit_shrinks_left at 4; play_level's redraw_exit runs the spin from the next frame. It ends by jumping to play_level rather than returning, so its return address (into check_exit at &1F8E) stays on the stack until the level ends; see play_level.
|
||||
| 203A | .hero_enters_exit←1← 1F8B JSR | |||
| STX scratch2 ; Keep the hero number | ||||
| 203D | JSR queue_exit_marker ; Sound the exit; mark the hero queue | |||
| 2040 | LDA #4 ; exit_offsets_x entry 0 = 4... | |||
| 2042 | STA exit_offsets_x ; ...never read: shrinks run from 4 down to 1 | |||
| 2045 | LDX shrunk_hero ; Restore the sprites of any hero shrunk before | |||
| 2048 | BMI start_hero_animation ; None (&FF): go straight on | |||
| 204A | JSR restore_hero_sprites ; Give that hero back their full-size sprites | |||
| 204D | JMP start_hero_animation ; ...then start this hero's spin | |||
Restore a hero's sprite sizesGive hero X back their full-size sprites after the exit animation has shrunk them. The descent narrows sprites base + 1 to base + 7 (base from hero_sprites) by a byte and shortens them by three rows after each of three turns, in sprite_widths and sprite_heights themselves. This sets the seven back to a whole cell, 4 bytes wide and 12 rows high, which is what every hero's walking sprites measure. Called by hero_enters_exit, before the next hero's descent shrinks their own sprites, and by play_level when the level ends, each time for shrunk_hero.
|
|||||||||||
| 2050 | .restore_hero_sprites←2← 1F32 JSR← 204A JSR | ||||||||||
| CLC ; The hero's sprites base + 1 to base + 7 | |||||||||||
| 2051 | LDA hero_sprites,x ; ...the hero's sprite base... | ||||||||||
| 2054 | ADC #1 ; ...+1: their first sprite... | ||||||||||
| 2056 | TAX ; ...in X, kept to restart Y for the heights... | ||||||||||
| 2057 | TAY ; ...and in Y, to walk the widths | ||||||||||
| 2058 | ADC #7 ; ...+7: stop before base + 8, left frame 1 | ||||||||||
| 205A | STA scratch ; ...kept as the end | ||||||||||
| 205D | LDA #4 ; Widths back to 4 bytes, a whole cell... | ||||||||||
| 205F | .restore_sprite_widths←1← 2066 BNE | ||||||||||
| STA sprite_widths,y ; Sprite Y back to 4 bytes wide | |||||||||||
| 2062 | INY ; Next of the seven, base + 1 to base + 7 | ||||||||||
| 2063 | CPY scratch ; Reached the end? | ||||||||||
| 2066 | BNE restore_sprite_widths ; No: widen the next | ||||||||||
| 2068 | TXA ; ...from the first sprite again... | ||||||||||
| 2069 | TAY ; ...in Y, to walk the heights | ||||||||||
| 206A | LDA #&0c ; ...heights back to 12 rows, a whole cell | ||||||||||
| 206C | .restore_sprite_heights←1← 2073 BNE | ||||||||||
| STA sprite_heights,y ; Sprite Y back to 12 rows high | |||||||||||
| 206F | INY ; Next of the seven | ||||||||||
| 2070 | CPY scratch ; Reached the end? | ||||||||||
| 2073 | BNE restore_sprite_heights ; No: restore the next | ||||||||||
| 2075 | RTS ; Return with the hero's sprites full size again | ||||||||||
| ; Set up the descent for the hero kept in scratch2. | |||||||||||
| 2076 | .start_hero_animation←2← 2048 BMI← 204D JMP | ||||||||||
| LDA #1 ; Start the animation for this hero... | |||||||||||
| 2078 | STA exit_busy ; ...the exit is busy... | ||||||||||
| 207B | LDA scratch2 ; ...the hero kept by hero_enters_exit... | ||||||||||
| 207E | STA exiting_hero ; ...is the one going down... | ||||||||||
| 2081 | STA shrunk_hero ; ...and the one whose sprites will shrink | ||||||||||
| 2084 | LDA #&ff ; ...turning from the start... | ||||||||||
| 2086 | STA exit_spin ; ...-1, so the first frame's +2 gives 1 | ||||||||||
| 2089 | LDA #4 ; ...for four turns, shrinking after the first three | ||||||||||
| 208B | STA exit_shrinks_left ; ...in exit_shrinks_left, counting turns 4 to 1 | ||||||||||
| 208E | JMP play_level ; Back to play_level, leaving the JSR's return address | ||||||||||
Drop the key a hero carriesLeave hero X's key behind beside the exit, so the heroes still playing can use it. Called by play_level's check_exit as the hero steps onto the exit, before they are taken out of play. find_open_neighbour picks the first wall-free cell of those above, right of and below the hero, or else the cell to the left whatever it holds; another key or an object may already lie there. The key's key_x/key_y are set to that cell, so update_game's draw_keys shows it from the next frame; hero_key is cleared and the key icon erased from the hero's panel section. A hero with no key moves key entry 0, which is never drawn or picked up.
|
|||||||
| 2091 | .drop_key←1← 1F48 JSR | ||||||
| LDA hero_x,x ; From the hero's cell (the exit)... | |||||||
| 2094 | STA cell_x ; ...is where the search starts: x... | ||||||
| 2097 | LDA hero_y,x ; ...and the hero's y... | ||||||
| 209A | STA cell_y ; ...and y | ||||||
| 209D | TXA ; ...find a wall-free cell next to it | ||||||
| 209E | PHA ; Keep the hero number... | ||||||
| 209F | JSR find_open_neighbour ; ...on the stack across the search | ||||||
| 20A2 | PLA ; Recover the hero number... | ||||||
| 20A3 | TAX ; ...into X, to find the key they carry | ||||||
| 20A4 | LDY hero_key,x ; Put the hero's key there (entry 0 if none) | ||||||
| 20A7 | LDA cell_x ; ...the free cell's x... | ||||||
| 20AA | STA key_x,y ; ...as the key's x... | ||||||
| 20AD | LDA cell_y ; ...and its y... | ||||||
| 20B0 | STA key_y,y ; ...as the key's y | ||||||
| 20B3 | LDA #0 ; The hero carries no key | ||||||
| 20B5 | STA hero_key,x ; ...in the hero's key slot | ||||||
| 20B8 | LDA #spr_blank_key_icon ; Erase the key icon from the hero's panel | ||||||
| 20BA | STA sprite_number ; ...as the sprite to plot | ||||||
| 20BC | LDA hero_panel_y,x ; ...from the hero's panel row... | ||||||
| 20BF | SEC ; ...set carry to subtract | ||||||
| 20C0 | SBC #&0d ; ...less 13: the key icon's row... | ||||||
| 20C2 | STA plot_y ; ...as plot_y, the icon's screen row | ||||||
| 20C4 | LDA #panel_left + 5 ; ...in panel column panel_left + 5... | ||||||
| 20C6 | STA plot_x ; ...as plot_x, the icon's column | ||||||
| 20C8 | TXA ; Keep the hero number... | ||||||
| 20C9 | PHA ; ...on the stack across plot_sprite | ||||||
| 20CA | JSR plot_sprite ; Plot the blank icon over the key icon | ||||||
| 20CD | PLA ; Recover the hero number... | ||||||
| 20CE | TAX ; ...into X, preserved for check_exit | ||||||
| 20CF | RTS ; Return with the key on the floor beside the exit | ||||||
Find a free cell next to a cellFind where drop_key, its only caller, can put down a key next to the exit. Starting from cell_x, cell_y, try the cells above, to the right and below, in that order, through test_wall, and leave cell_x, cell_y on the first without a wall; failing all three, leave them on the cell to the left without testing it, so a key can land in a wall there. Only walls are tested, not keys, objects or creatures. map_ptr is left pointing at the room of the last cell tested.
|
|||||||||||||||||
| 20D0 | .find_open_neighbour←1← 209F JSR | ||||||||||||||||
| DEC cell_y ; Try the cell above first | |||||||||||||||||
| 20D3 | JSR test_wall ; ...is there a wall in it? | ||||||||||||||||
| 20D6 | CPY #0 ; Y = 0 if no wall there | ||||||||||||||||
| 20D8 | BNE try_cell_right ; Wall: try the cell to the right | ||||||||||||||||
| 20DA | RTS ; No wall: leave cell_x, cell_y on it | ||||||||||||||||
| 20DB | .try_cell_right←1← 20D8 BNE | ||||||||||||||||
| INC cell_y ; Then the cell to the right | |||||||||||||||||
| 20DE | INC cell_x ; ...x + 1 (y back to the starting row) | ||||||||||||||||
| 20E1 | JSR test_wall ; ...is there a wall in it? | ||||||||||||||||
| 20E4 | CPY #0 ; Y = 0 if no wall there | ||||||||||||||||
| 20E6 | BNE try_cell_below ; Wall: try the cell below | ||||||||||||||||
| 20E8 | RTS ; No wall: leave cell_x, cell_y on it | ||||||||||||||||
| 20E9 | .try_cell_below←1← 20E6 BNE | ||||||||||||||||
| DEC cell_x ; Then the cell below | |||||||||||||||||
| 20EC | INC cell_y ; ...y + 1 (x back to the starting column) | ||||||||||||||||
| 20EF | JSR test_wall ; ...is there a wall in it? | ||||||||||||||||
| 20F2 | CPY #0 ; Y = 0 if no wall there | ||||||||||||||||
| 20F4 | BNE try_cell_left ; Wall: fall back on the cell to the left | ||||||||||||||||
| 20F6 | RTS ; No wall: leave cell_x, cell_y on it | ||||||||||||||||
| 20F7 | .try_cell_left←1← 20F4 BNE | ||||||||||||||||
| DEC cell_y ; Otherwise the cell to the left | |||||||||||||||||
| 20FA | DEC cell_x ; ...x - 1: unchecked, the last resort | ||||||||||||||||
| 20FD | RTS ; Return, Y non-zero | ||||||||||||||||
| 20FE | EQUB &01, &3F ; Not referenced | ||||||||||||||||
| ; Map of the cells that cannot hold an object, in the same ; layout as room_walls, from the level file: a bit is clear ; where an object lies (and on a few other cells), so the object ; list need only be searched when a hero steps onto a clear bit. | |||||||||||||||||
| 2100 | .object_free_map←1Used as index base by← 156D STA | ||||||||||||||||
| EQUB &00, &02, &07, &07, &1F, &3F, ; Not read: unpack_level &7D, &7F, &00, &30, &78, &FD, ; copies each level's &7F, &FF, &80, &00 ; object-free map here | |||||||||||||||||
| 2110 | EQUB &00, &60, &E0, &C0, &DF, &C0, &1F, &0F, &00, &58, &58, &58, &D8, &18, &F8, &80 ; ...entries 16-31, not read | ||||||||||||||||
| 2120 | EQUB &76, &3E, &5F, &6E, &7E, &00, &7F, &7F, &00, &66, &66, &7E, &7E, &66, &66, &00 ; ...entries 32-47, not read | ||||||||||||||||
| 2130 | EQUB &1F, &1F, &03, &03, &FF, &03, &03, &03, &80, &80, &80, &80, &80, &F6, &FE, &F6 ; ...entries 48-63, not read | ||||||||||||||||
| 2140 | EQUB &7F, &00, &3F, &2F, &37, &37, &2F, &37, &C0, &03, &C4, &86, &40, &00, &80, &C1 ; ...entries 64-79, not read | ||||||||||||||||
| 2150 | EQUB &03, &E3, &E0, &E1, &41, &41, &00, &FF, &FE, &FE, &00, &00, &00, &00, &00, &8A ; ...entries 80-95, not read | ||||||||||||||||
| 2160 | EQUB &00, &00, &00, &00, &7E, &7F, &7E, &00, &01, &01, &01, &3F, &3F, &BF, &3F, &3F ; ...entries 96-111, not read | ||||||||||||||||
| 2170 | EQUB &F7, &FF, &C1, &F7, &C1, &FF, &F7, &BF, &8E, &9E, &DE, &9C, &9E, &8E, &8E, &80 ; ...entries 112-127, not read | ||||||||||||||||
| 2180 | EQUB &7E, &3E, &7E, &00, &7C, &7A, &7E, &00, &2F, &1F, &00, &00, &00, &CE, &AE, &5E ; ...entries 128-143, not read | ||||||||||||||||
| 2190 | EQUB &1F, &1F, &1F, &1B, &17, &1F, &00, &01, &80, &80, &80, &80, &80, &80, &02, &02 ; ...entries 144-159, not read | ||||||||||||||||
| 21A0 | EQUB &7E, &7A, &7E, &00, &7E, &3E, &7F, &00, &BE, &0E, &0E, &0F, &0E, &0E, &BE, &00 ; ...entries 160-175, not read | ||||||||||||||||
| 21B0 | EQUB &01, &01, &0F, &DF, &07, &03, &01, &00, &08, &08, &5A, &FE, &FE, &FC, &B8, &00 ; ...entries 176-191, not read | ||||||||||||||||
| 21C0 | EQUB &00, &00, &00, &00, &00, ; ...entries 192-200, not &00, &00, &00, &00 ; read | ||||||||||||||||
| 21C9 | EQUB &08, &2A, &00, &00, &00, &00, &00 ; Not referenced | ||||||||||||||||
| ; Data of sprite &53, &54, &55, &56, &57, &58, &59, &5A, &5B, ; &5C, &5D, &5E: 4 bytes x 12 rows. | |||||||||||||||||
| 21D0 | .sprite_drainer | ||||||||||||||||
| EQUB &11, &33, &33, &22, &33, &33, &33, &33, &33, &FF, &C0, &33, &33, &FF, &C0, &33, &33, &FF, &C0, &33, &33, &FF, &C0, &33, &33, &FF, &C0, &33, &33, &FF, &C0, &33, &33, &FF, &C0, &33, &33, &FF, &C0, &33, &33, &33, &33, &33, &11, &33, &33, &22 | |||||||||||||||||
| ; Map x of each door (entries 1-20). | |||||||||||||||||
| 2200 | .door_x←4Used as index base by← 152C STA← 1CD8 LDA← 1D8B STA← 77FE LDA | ||||||||||||||||
| EQUB &FF, &FF, &FF, &04, &FF, &FF, ; Not read: unpack_level &06, &FF, &11, &FF, &FF, &FF, ; copies each level's &1A, &03, &03, &0B ; doors here | |||||||||||||||||
| 2210 | EQUB &FF, &03, &09, &12, &FF ; ...entries 16-20, not read | ||||||||||||||||
| 2215 | EQUB &FF, &FF, &FF, &FF, &FF, &FF, &FF, &FF, ; Not &FF, &FF, &FF ; referenced | ||||||||||||||||
| ; Map y of each door. | |||||||||||||||||
| 2220 | .door_y←4Used as index base by← 1532 STA← 1CE3 LDA← 1D8E STA← 7804 LDA | ||||||||||||||||
| EQUB &FF, &FF, &FF, &0D, &FF, &FF, ; Not read: unpack_level &11, &FF, &16, &FF, &FF, &FF, ; copies each level's &1A, &23, &27, &25 ; doors here | |||||||||||||||||
| 2230 | EQUB &FF, &2B, &2E, &2B, &FF ; ...entries 16-20, not read | ||||||||||||||||
| 2235 | EQUB &FF, &FF, &FF, &FF, &FF, &FF, &FF, &FF, ; Not &FF, &FF, &FF ; referenced | ||||||||||||||||
| ; Sprite of each door. | |||||||||||||||||
| 2240 | .door_sprite←2Used as index base by← 1538 STA← 7810 LDA | ||||||||||||||||
| EQUB &FF, &1C, &1C, &1D, &1C, &1C, ; Not read: unpack_level &1D, &1D, &1D, &1D, &1D, &1C, ; copies each level's &1C, &1D, &1D, &1C ; door sprites here | |||||||||||||||||
| 2250 | EQUB &1D, &1D, &1C, &1C, &FF ; ...entries 16-20, not read | ||||||||||||||||
| 2255 | EQUB &FF, &FF, &FF, &FF, &FF, &FF, &FF, &FF, ; Not &FF, &FF, &FF ; referenced | ||||||||||||||||
| ; Map x of each key lying on the floor (entries 1-20); key n ; opens door n. | |||||||||||||||||
| 2260 | .key_x←7Used as index base by← 1543 STA← 1DCE LDA← 1E00 STA← 1E45 LDA← 1E8C STA← 1EA1 STA← 20AA STA | ||||||||||||||||
| EQUB &13, &FF, &FF, &1B, &FF, &FF, ; Not read: unpack_level &17, &FF, &1C, &FF, &FF, &FF, ; copies each level's &02, &15, &04, &09 ; keys here | |||||||||||||||||
| 2270 | EQUB &FF, &04, &19, &17, &FF ; ...entries 16-20, not read | ||||||||||||||||
| 2275 | EQUB &FF, &FF, &FF, &FF, &FF, &FF, &FF, &FF, ; Not &FF, &FF, &FF ; referenced | ||||||||||||||||
| ; Map y of each key on the floor. | |||||||||||||||||
| 2280 | .key_y←7Used as index base by← 1549 STA← 1DD4 LDA← 1E06 STA← 1E4D LDA← 1E92 STA← 1EA4 STA← 20B0 STA | ||||||||||||||||
| EQUB &25, &FF, &FF, &06, &FF, &FF, ; Not read: unpack_level &09, &FF, &18, &FF, &FF, &FF, ; copies each level's &29, &04, &0C, &14 ; keys here | |||||||||||||||||
| 2290 | EQUB &FF, &0F, &03, &04, &FF ; ...entries 16-20, not read | ||||||||||||||||
| 2295 | EQUB &FF, &FF, &FF, &FF, &FF, &FF, &FF, &FF, ; Not &FF, &FF, &FF ; referenced | ||||||||||||||||
| ; Data of sprite &51: 4 bytes x 12 rows. | |||||||||||||||||
| 22A0 | .sprite_exit | ||||||||||||||||
| EQUB &03, &03, &03, &03, &02, &00, &00, &01, &02, &00, &00, &01, &02, &00, &00, &01, &02, &00, &00, &01, &02, &00, &00, &01, &02, &00, &00, &01, &02, &00, &00, &01, &02, &00, &00, &01, &02, &00, &00, &01, &02, &00, &00, &01, &03, &03, &03, &03 | |||||||||||||||||
| ; Data of sprite &52: 2 bytes x 3 rows. | |||||||||||||||||
| 22D0 | .sprite_key_icon | ||||||||||||||||
| EQUB &00, &05, &0F, &0F, &0F, &05 | |||||||||||||||||
UnusedZero bytes, which nothing reads. |
|
| 22D6 | EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 ; Zer os |
| ; Number of the key each hero carries, or 0. | |
| 22E0 | .hero_key←10Used as index base by← 159F STA← 1CF2 CMP← 1D95 STA← 1DEB LDA← 1DFA LDY← 1E0B STA← 1E86 LDX← 1E97 STA← 20A4 LDY← 20B5 STA |
| EQUB &00, &00, &00, &00, &00 | |
| ; Set when the hero has just swapped keys, so the key dropped is ; not picked straight back up. | |
| 22E5 | .hero_key_dropped←4Used as index base by← 15A2 STA← 1E28 LDA← 1E2F STA← 1E9C STA |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Hero map x, kept for the door and key checks. | |
| 22F0 | .hero_door_x←4Used as index base by← 1079 LDA← 15A5 STA← 1CC8 LDA← 6F9B STA |
| EQUB &1A, &09, &00, &16, &00 | |
| ; Hero map y, kept for the door and key checks. | |
| 22F5 | .hero_door_y←4Used as index base by← 108A LDA← 15A8 STA← 1CCE LDA← 6FA1 STA |
| EQUB &06, &1D, &00, &09, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &2D: 4 bytes x 12 rows. | |
| 2300 | .sprite_magic_user_up_0 |
| EQUB &01, &0A, &00, &00, &03, &0A, &0B, &00, &03, &00, &0B, &02, &03, &00, &00, &03, &03, &00, &0A, &03, &03, &10, &1A, &01, &01, &27, &0F, &23, &01, &33, &33, &23, &01, &13, &33, &00, &03, &13, &33, &00, &03, &03, &22, &00, &03, &03, &00, &00 | |
| ; Data of sprite &2E: 4 bytes x 12 rows. | |
| 2330 | .sprite_magic_user_up_1 |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &0F, &00, &00, &0F, &03, &00, &0A, &03, &03, &10, &1A, &01, &01, &27, &0F, &23, &01, &33, &33, &23, &01, &13, &33, &03, &00, &13, &33, &03, &00, &03, &23, &03, &00, &01, &01, &03 | |
| ; Data of sprite &2F: 4 bytes x 12 rows. | |
| 2360 | .sprite_magic_user_right_0 |
| EQUB &03, &00, &03, &00, &03, &03, &03, &02, &03, &13, &00, &0F, &03, &27, &00, &00, &13, &32, &00, &00, &13, &27, &0A, &00, &13, &27, &0A, &00, &13, &32, &00, &00, &01, &27, &00, &0A, &00, &13, &01, &0A, &00, &03, &03, &0A, &00, &01, &03, &00 | |
| ; Data of sprite &30: 4 bytes x 12 rows. | |
| 2390 | .sprite_magic_user_right_1 |
| EQUB &00, &00, &00, &00, &00, &01, &03, &0A, &00, &13, &07, &00, &01, &27, &00, &00, &11, &32, &00, &00, &11, &27, &0A, &00, &13, &27, &0A, &00, &13, &32, &00, &00, &03, &27, &05, &00, &03, &13, &07, &00, &03, &03, &07, &00, &03, &01, &02, &00 | |
| ; Data of sprite &31: 4 bytes x 12 rows. | |
| 23C0 | .sprite_magic_user_down_0 |
| EQUB &00, &00, &03, &03, &00, &11, &03, &03, &00, &33, &23, &03, &00, &33, &23, &02, &13, &33, &33, &02, &13, &0F, &1B, &02, &02, &25, &20, &03, &03, &05, &00, &03, &03, &00, &00, &03, &01, &07, &00, &03, &00, &07, &05, &03, &00, &00, &05, &02 | |
| ; Data of sprite &32: 4 bytes x 12 rows. | |
| 23F0 | .sprite_magic_user_down_1 |
| EQUB &03, &02, &02, &00, &03, &13, &03, &00, &03, &33, &23, &00, &03, &33, &23, &02, &13, &33, &33, &02, &13, &0F, &1B, &02, &02, &25, &20, &03, &03, &05, &00, &03, &0F, &00, &00, &0F, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &33: 4 bytes x 12 rows. | |
| 2420 | .sprite_magic_user_left_0 |
| EQUB &00, &03, &02, &00, &05, &03, &03, &00, &05, &02, &23, &00, &05, &00, &1B, &02, &00, &00, &31, &23, &00, &05, &1B, &23, &00, &05, &1B, &23, &00, &00, &31, &23, &00, &00, &1B, &03, &0F, &00, &23, &03, &01, &03, &03, &03, &00, &03, &00, &03 | |
| ; Data of sprite &34: 4 bytes x 12 rows. | |
| 2450 | .sprite_magic_user_left_1 |
| EQUB &00, &01, &02, &03, &00, &0B, &03, &03, &00, &0B, &23, &03, &00, &0A, &1B, &03, &00, &00, &31, &23, &00, &05, &1B, &23, &00, &05, &1B, &22, &00, &00, &31, &22, &00, &00, &1B, &02, &00, &0B, &23, &00, &05, &03, &02, &00, &00, &00, &00, &00 | |
| ; Data of sprite &35: 4 bytes x 12 rows. | |
| 2480 | .sprite_barbarian_up_0 |
| EQUB &00, &00, &3F, &3F, &00, &0F, &05, &0A, &01, &0F, &2D, &1E, &01, &0F, &05, &0A, &0B, &02, &00, &03, &0F, &1A, &20, &0F, &0F, &34, &38, &0F, &0F, &30, &30, &0F, &0F, &34, &38, &0F, &0B, &1A, &25, &07, &05, &03, &0B, &0A, &00, &0B, &07, &00 | |
| ; Data of sprite &36: 4 bytes x 12 rows. | |
| 24B0 | .sprite_barbarian_up_1 |
| EQUB &00, &15, &3F, &2A, &05, &0A, &0F, &00, &07, &1E, &0F, &28, &07, &0A, &0F, &00, &03, &02, &01, &02, &0F, &10, &25, &0A, &0F, &34, &38, &0F, &0F, &30, &30, &0F, &0F, &34, &38, &0F, &0F, &12, &21, &0F, &01, &0B, &07, &02, &00, &07, &03, &00 | |
| ; Data of sprite &37: 4 bytes x 12 rows. | |
| 24E0 | .sprite_barbarian_right_0 |
| EQUB &00, &0F, &02, &00, &05, &0B, &0F, &0A, &05, &0B, &0F, &0A, &0B, &1A, &05, &0A, &07, &34, &20, &28, &0B, &34, &20, &28, &03, &34, &20, &28, &07, &34, &20, &3D, &0B, &12, &05, &1F, &01, &0F, &07, &1F, &05, &0F, &07, &1F, &00, &0F, &03, &3D | |
| ; Data of sprite &38: 4 bytes x 12 rows. | |
| 2510 | .sprite_barbarian_right_1 |
| EQUB &00, &0F, &02, &28, &05, &0B, &0F, &0A, &05, &0B, &0F, &0A, &03, &1A, &05, &0A, &0B, &34, &20, &28, &03, &34, &20, &3D, &0B, &34, &25, &1F, &07, &34, &25, &1F, &0B, &1A, &07, &1F, &05, &0F, &07, &15, &05, &0F, &03, &00, &00, &0F, &00, &00 | |
| ; Data of sprite &39: 4 bytes x 12 rows. | |
| 2540 | .sprite_barbarian_down_0 |
| EQUB &00, &0B, &07, &00, &05, &07, &03, &0A, &0B, &1A, &25, &07, &0F, &34, &38, &0F, &0F, &30, &30, &0F, &0F, &34, &38, &0F, &0F, &10, &25, &0F, &03, &00, &01, &07, &05, &0A, &0F, &02, &2D, &1E, &0F, &02, &05, &0A, &0F, &00, &3F, &3F, &00, &00 | |
| ; Data of sprite &3A: 4 bytes x 12 rows. | |
| 2570 | .sprite_barbarian_down_1 |
| EQUB &00, &03, &0B, &00, &01, &0B, &07, &02, &0F, &12, &21, &0F, &0F, &34, &38, &0F, &0F, &30, &30, &0F, &0F, &34, &38, &0F, &05, &1A, &20, &0F, &01, &02, &01, &03, &00, &0F, &05, &0B, &14, &0F, &2D, &0B, &00, &0F, &05, &0A, &15, &3F, &2A, &00 | |
| ; Data of sprite &3B: 4 bytes x 12 rows. | |
| 25A0 | .sprite_barbarian_left_0 |
| EQUB &3E, &03, &0F, &00, &2F, &0B, &0F, &0A, &2F, &0B, &0F, &02, &2F, &0A, &21, &07, &3E, &10, &38, &0B, &14, &10, &38, &03, &14, &10, &38, &07, &14, &10, &38, &0B, &05, &0A, &25, &07, &05, &0F, &07, &0A, &05, &0F, &07, &0A, &00, &01, &0F, &00 | |
| ; Data of sprite &3C: 4 bytes x 12 rows. | |
| 25D0 | .sprite_barbarian_left_1 |
| EQUB &00, &00, &0F, &00, &00, &03, &0F, &0A, &2A, &0B, &0F, &0A, &2F, &0B, &25, &07, &2F, &1A, &38, &0B, &2F, &1A, &38, &07, &3E, &10, &38, &03, &14, &10, &38, &07, &05, &0A, &25, &03, &05, &0F, &07, &0A, &05, &0F, &07, &0A, &14, &01, &0F, &00 | |
| ; Data of sprite &3D: 4 bytes x 12 rows. | |
| 2600 | .sprite_fighter_up_0 |
| EQUB &00, &15, &00, &00, &00, &00, &2A, &00, &28, &0A, &15, &00, &2D, &0E, &00, &2B, &39, &0E, &00, &03, &39, &26, &0A, &33, &39, &23, &0B, &33, &39, &27, &0F, &33, &00, &36, &3C, &22, &00, &3E, &3C, &2A, &15, &00, &0C, &15, &00, &00, &0C, &00 | |
| ; Data of sprite &3E: 4 bytes x 12 rows. | |
| 2630 | .sprite_fighter_up_1 |
| EQUB &00, &28, &00, &15, &00, &28, &00, &15, &14, &00, &00, &15, &14, &27, &04, &1D, &39, &27, &04, &1D, &39, &22, &0E, &1D, &11, &32, &1A, &03, &00, &27, &0F, &33, &00, &36, &3C, &33, &00, &3E, &3C, &2A, &15, &04, &08, &15, &00, &04, &08, &00 | |
| ; Data of sprite &3F: 4 bytes x 12 rows. | |
| 2660 | .sprite_fighter_right_0 |
| EQUB &00, &3C, &3C, &28, &00, &11, &22, &00, &2A, &33, &27, &0A, &15, &39, &05, &00, &14, &06, &08, &00, &14, &0F, &08, &00, &14, &0F, &00, &00, &1C, &02, &00, &15, &1D, &28, &00, &2A, &3B, &33, &17, &00, &00, &33, &0A, &00, &00, &01, &0A, &00 | |
| ; Data of sprite &40: 4 bytes x 12 rows. | |
| 2690 | .sprite_fighter_right_1 |
| EQUB &00, &00, &28, &00, &2A, &33, &36, &00, &15, &39, &33, &28, &1C, &02, &11, &1E, &1C, &0F, &00, &0A, &14, &0F, &00, &00, &14, &02, &00, &00, &15, &2C, &08, &00, &3B, &26, &08, &00, &11, &23, &00, &00, &11, &23, &3F, &3F, &00, &00, &00, &00 | |
| ; Data of sprite &41: 4 bytes x 12 rows. | |
| 26C0 | .sprite_fighter_down_0 |
| EQUB &00, &0C, &00, &00, &2A, &0C, &00, &2A, &15, &3C, &3D, &00, &11, &3C, &39, &00, &33, &0F, &1B, &36, &33, &07, &13, &36, &33, &05, &19, &36, &03, &00, &0D, &36, &17, &00, &0D, &1E, &00, &2A, &05, &14, &00, &15, &00, &00, &00, &00, &2A, &00 | |
| ; Data of sprite &42: 4 bytes x 12 rows. | |
| 26F0 | .sprite_fighter_down_1 |
| EQUB &00, &04, &08, &00, &2A, &04, &08, &2A, &15, &3C, &3D, &00, &33, &3C, &39, &00, &33, &0F, &1B, &00, &03, &25, &31, &22, &2E, &0D, &11, &36, &2E, &08, &1B, &36, &2E, &08, &1B, &28, &2A, &00, &00, &28, &2A, &00, &14, &00, &2A, &00, &14, &00 | |
| ; Data of sprite &43: 4 bytes x 12 rows. | |
| 2720 | .sprite_fighter_left_0 |
| EQUB &00, &05, &02, &00, &00, &05, &33, &00, &00, &2B, &33, &37, &15, &00, &14, &2E, &2A, &00, &01, &2C, &00, &00, &0F, &28, &00, &04, &0F, &28, &00, &04, &09, &28, &00, &0A, &36, &2A, &05, &1B, &33, &15, &00, &11, &22, &00, &14, &3C, &3C, &00 | |
| ; Data of sprite &44: 4 bytes x 12 rows. | |
| 2750 | .sprite_fighter_left_1 |
| EQUB &3F, &3F, &13, &22, &00, &00, &13, &22, &00, &04, &19, &37, &00, &04, &1C, &2A, &00, &00, &01, &28, &00, &00, &0F, &28, &05, &00, &0F, &2C, &2D, &22, &01, &2C, &14, &33, &36, &2A, &00, &39, &33, &15, &00, &14, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &45: 4 bytes x 12 rows. | |
| 2780 | .sprite_fireball_up |
| EQUB &00, &00, &0A, &00, &00, &01, &03, &00, &00, &05, &07, &00, &00, &01, &0B, &00, &00, &05, &07, &00, &00, &05, &07, &00, &00, &05, &0F, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00 | |
| ; Data of sprite &46: 4 bytes x 12 rows. | |
| 27B0 | .sprite_fireball_right |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &05, &0A, &00, &0F, &0B, &07, &0F, &0B, &07, &07, &00, &0F, &0B, &07, &00, &00, &05, &0A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &47: 4 bytes x 12 rows. | |
| 27E0 | .sprite_fireball_down |
| EQUB &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &05, &0F, &00, &00, &05, &07, &00, &00, &05, &07, &00, &00, &01, &0B, &00, &00, &05, &07, &00, &00, &01, &03, &00, &00, &00, &0A, &00 | |
| ; Data of sprite &48: 4 bytes x 12 rows. | |
| 2810 | .sprite_fireball_left |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &05, &0A, &00, &00, &0B, &07, &0F, &00, &0B, &0B, &07, &0F, &0B, &07, &0F, &00, &05, &0A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &4D: 4 bytes x 12 rows. | |
| 2840 | .sprite_axe_up |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &15, &2A, &00, &00, &3F, &3F, &00, &00, &15, &2A, &14, &3C, &3C, &3C, &00, &00, &15, &2A, &00, &00, &3F, &3F, &00, &00, &15, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &4E: 4 bytes x 12 rows. | |
| 2870 | .sprite_axe_right |
| EQUB &00, &00, &00, &00, &00, &14, &00, &00, &00, &14, &00, &00, &00, &14, &00, &00, &00, &14, &00, &00, &15, &14, &15, &00, &15, &3E, &3F, &00, &15, &3E, &3F, &00, &15, &3E, &3F, &00, &15, &14, &15, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &4F: 4 bytes x 12 rows. | |
| 28A0 | .sprite_axe_down |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &15, &2A, &00, &00, &3F, &3F, &00, &00, &15, &2A, &00, &00, &3C, &3C, &3C, &28, &15, &2A, &00, &00, &3F, &3F, &00, &00, &15, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &50: 4 bytes x 12 rows. | |
| 28D0 | .sprite_axe_left |
| EQUB &00, &00, &00, &00, &00, &2A, &28, &2A, &00, &3F, &3D, &2A, &00, &3F, &3D, &2A, &00, &3F, &3D, &2A, &00, &2A, &28, &2A, &00, &00, &28, &00, &00, &00, &28, &00, &00, &00, &28, &00, &00, &00, &28, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &1B: 4 bytes x 12 rows. | |
| 2900 | .sprite_key |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &0A, &00, &00, &05, &05, &00, &00, &05, &05, &0F, &0F, &0F, &05, &0A, &0A, &05, &05, &0A, &0A, &05, &05, &0A, &0A, &00, &0A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &28: 4 bytes x 12 rows. | |
| 2930 | .sprite_treasure |
| EQUB &03, &03, &02, &02, &13, &50, &02, &02, &02, &24, &17, &03, &47, &00, &02, &03, &12, &0D, &02, &03, &02, &4F, &02, &03, &06, &32, &02, &03, &47, &02, &02, &03, &12, &A5, &02, &03, &07, &08, &17, &03, &06, &B0, &02, &02, &03, &03, &02, &02 | |
| ; Data of sprite &29: 4 bytes x 12 rows. | |
| 2960 | .sprite_food |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &2A, &00, &00, &00, &15, &00, &00, &00, &2F, &2A, &0F, &00, &2F, &0F, &0F, &0A, &00, &0F, &03, &0B, &00, &05, &0F, &03, &00, &05, &07, &02, &00, &00, &03, &02, &00, &00, &03, &00 | |
| 2990 | EQUB &05, &0F, &0F, &00, &0A, &0F, &0F, &0A, &0A, &00, &05, &00, &05, &30, &20, &0A, &05, &00, &00, &0A, &00, &1A, &30, &05, &00, &0A, &00, &05, &0F, &1A, &30, &25, &0F, &00, &00, &0A, &0A, &30, &30, &0A, &05, &00, &00, &0A, &00, &0F, &0F, &00 ; Not referenced |
| ; Data of sprite &2B: 4 bytes x 12 rows. | |
| 29C0 | .sprite_teleporter |
| EQUB &3F, &3F, &3F, &3F, &3E, &3C, &3C, &38, &3E, &3C, &3C, &38, &3E, &3F, &3F, &38, &3E, &3E, &38, &38, &3E, &3E, &38, &38, &3E, &3E, &38, &38, &3E, &3E, &38, &38, &3E, &30, &30, &38, &3E, &3C, &3C, &38, &3E, &3C, &3C, &38, &30, &30, &30, &30 | |
| 29F0 | EQUB &00, &2C, &00, &00, &00, &2C, &08, &00, &00, &0C, &08, &00, &04, &0F, &0E, &00 ; Not referenced |
| ; Data of sprite &1E: 2 bytes x 10 rows. | |
| 2A00 | .sprite_digit_0 |
| EQUB &04, &08, &08, &0C, &08, &0C, &08, &0C, &08, &0C, &0C, &04, &0C, &04, &0C, &04, &0C, &04, &04, &08 | |
| ; Data of sprite &1F: 2 bytes x 10 rows. | |
| 2A14 | .sprite_digit_1 |
| EQUB &04, &00, &0C, &00, &04, &00, &04, &00, &04, &00, &04, &00, &04, &00, &04, &00, &04, &00, &0C, &00 | |
| ; Data of sprite &20: 2 bytes x 10 rows. | |
| 2A28 | .sprite_digit_2 |
| EQUB &04, &08, &08, &04, &08, &04, &00, &04, &00, &08, &04, &00, &08, &00, &08, &04, &08, &08, &0C, &0C | |
| ; Data of sprite &21: 2 bytes x 10 rows. | |
| 2A3C | .sprite_digit_3 |
| EQUB &04, &08, &08, &04, &00, &04, &00, &04, &04, &08, &04, &08, &00, &04, &00, &04, &0C, &04, &04, &08 | |
| ; Data of sprite &22: 2 bytes x 10 rows. | |
| 2A50 | .sprite_digit_4 |
| EQUB &00, &08, &04, &08, &04, &08, &08, &08, &08, &0C, &0C, &08, &00, &0C, &00, &08, &00, &08, &04, &08 | |
| ; Data of sprite &23: 2 bytes x 10 rows. | |
| 2A64 | .sprite_digit_5 |
| EQUB &0C, &0C, &08, &04, &08, &00, &08, &00, &04, &00, &00, &08, &00, &04, &04, &04, &08, &04, &04, &08 | |
| ; Data of sprite &24: 2 bytes x 10 rows. | |
| 2A78 | .sprite_digit_6 |
| EQUB &00, &04, &00, &08, &04, &00, &04, &00, &04, &08, &08, &04, &08, &04, &08, &04, &08, &04, &04, &08 | |
| ; Data of sprite &25: 2 bytes x 10 rows. | |
| 2A8C | .sprite_digit_7 |
| EQUB &0C, &0C, &00, &04, &00, &08, &00, &08, &00, &08, &04, &00, &04, &00, &04, &00, &04, &00, &0C, &08 | |
| ; Data of sprite &26: 2 bytes x 10 rows. | |
| 2AA0 | .sprite_digit_8 |
| EQUB &04, &08, &08, &04, &08, &04, &08, &04, &04, &08, &08, &04, &08, &04, &08, &04, &08, &04, &04, &08 | |
| ; Data of sprite &27: 2 bytes x 10 rows. | |
| 2AB4 | .sprite_digit_9 |
| EQUB &04, &08, &08, &04, &08, &04, &08, &04, &08, &04, &04, &08, &00, &08, &00, &08, &04, &00, &08, &00 | |
| ; Data of sprite &1D: 4 bytes x 12 rows. | |
| 2AC8 | .sprite_door_horizontal |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &3F, &3F, &3F, &3F, &3E, &3C, &3C, &38, &3E, &3C, &3C, &38, &3E, &3C, &3C, &38, &3E, &3C, &3C, &38, &30, &30, &30, &30, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| 2AF8 | EQUB &0F, &1A, &30, &20, ; Not referenced &00, &00, &00, &25 |
| ; Data of sprite &16: 4 bytes x 12 rows. | |
| 2B00 | .sprite_sparkle_0 |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &15, &2A, &00, &00, &3F, &3F, &00, &00, &3F, &3F, &00, &00, &15, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &17: 4 bytes x 12 rows. | |
| 2B30 | .sprite_sparkle_1 |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &3F, &3F, &00, &00, &00, &00, &00, &15, &15, &2A, &2A, &15, &00, &00, &2A, &15, &00, &00, &2A, &15, &15, &2A, &2A, &00, &00, &00, &00, &00, &3F, &3F, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &18: 4 bytes x 12 rows. | |
| 2B60 | .sprite_sparkle_2 |
| EQUB &00, &00, &00, &00, &15, &3F, &3F, &2A, &00, &3F, &3F, &00, &2A, &00, &00, &15, &3F, &00, &00, &3F, &3F, &15, &2A, &3F, &3F, &15, &2A, &3F, &3F, &00, &00, &3F, &2A, &00, &00, &15, &00, &3F, &3F, &00, &15, &3F, &3F, &2A, &00, &00, &00, &00 | |
| ; Data of sprite &19: 4 bytes x 12 rows. | |
| 2B90 | .sprite_sparkle_3 |
| EQUB &3F, &00, &00, &3F, &3F, &2A, &15, &3F, &2A, &2A, &15, &15, &2A, &00, &00, &15, &3F, &15, &2A, &3F, &15, &2A, &15, &2A, &15, &2A, &15, &2A, &3F, &15, &2A, &3F, &2A, &00, &00, &15, &2A, &2A, &15, &15, &3F, &2A, &15, &3F, &3F, &00, &00, &3F | |
| ; Data of sprite &2C: 4 bytes x 12 rows. | |
| 2BC0 | .sprite_trapdoor |
| EQUB &3C, &3C, &3C, &3C, &29, &03, &03, &16, &3F, &12, &03, &16, &3F, &03, &03, &34, &29, &03, &21, &16, &29, &03, &03, &16, &29, &21, &21, &16, &29, &03, &03, &34, &3F, &03, &21, &16, &3F, &03, &03, &16, &29, &21, &12, &16, &3C, &3C, &3C, &3C | |
| 2BF0 | EQUB &00, &00, &00, &00, &04, &00, &00, &00, &20, &00, &00, &00, &FD, &14, &93, &00 ; Not referenced |
| ; Data of sprite &11: 4 bytes x 12 rows. | |
| 2C00 | .sprite_arrow_up |
| EQUB &00, &00, &00, &00, &00, &15, &00, &00, &00, &15, &00, &00, &00, &05, &00, &00, &00, &05, &00, &00, &00, &05, &00, &00, &00, &05, &00, &00, &00, &05, &00, &00, &00, &05, &00, &00, &00, &0C, &08, &00, &00, &08, &08, &00, &00, &00, &00, &00 | |
| ; Data of sprite &12: 4 bytes x 12 rows. | |
| 2C30 | .sprite_arrow_right |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &0C, &00, &00, &00, &04, &0F, &0F, &2A, &0C, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &13: 4 bytes x 12 rows. | |
| 2C60 | .sprite_arrow_down |
| EQUB &00, &00, &00, &00, &00, &04, &04, &00, &00, &04, &0C, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &2A, &00, &00, &00, &2A, &00, &00, &00, &00, &00 | |
| ; Data of sprite &14: 4 bytes x 12 rows. | |
| 2C90 | .sprite_arrow_left |
| EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &0C, &15, &0F, &0F, &08, &00, &00, &00, &0C, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Data of sprite &1C: 4 bytes x 12 rows. | |
| 2CC0 | .sprite_door_vertical |
| EQUB &00, &3F, &3A, &00, &00, &3E, &38, &00, &00, &3E, &38, &00, &00, &3E, &38, &00, &00, &3E, &38, &00, &00, &3E, &38, &00, &00, &3E, &38, &00, &00, &3E, &38, &00, &00, &3E, &38, &00, &00, &3E, &38, &00, &00, &3E, &38, &00, &00, &30, &30, &00 | |
| 2CF0 | EQUB &01, &00, &00, &00, &17, &00, &00, &90, &17, &00, &00, &00, &00, &00, &00, &00 ; Not referenced |
| ; Data of sprite 0, the wall block (4 bytes x 12 rows), replaced ; by each level's own from the level file. | |
| 2D00 | .wall_sprite←1Used as index base by← 157A STA |
| EQUB &0F, &0B, &0F, &07, &03, &0F, &0F, &0F, &0F, &1F, &2F, &0B, &0F, &2F, &0B, &0F, &1F, &0F, &0F, &07, &1F, &1F, &0F, &07, &17, &0F, &07, &07, &1F, &0F, &0F, &07, &0F, &2F, &0B, &0F, &07, &0B, &07, &0F, &0F, &0F, &0F, &03, &0B, &0F, &0F, &0F | |
| ; Data of sprite &01: 4 bytes x 12 rows. | |
| 2D30 | .sprite_ranger_up_0 |
| EQUB &00, &03, &0B, &00, &01, &00, &0A, &02, &02, &00, &04, &01, &01, &02, &04, &00, &0B, &02, &00, &08, &0B, &07, &00, &08, &1C, &25, &34, &08, &1C, &0F, &1E, &08, &04, &3C, &29, &08, &04, &3C, &0C, &00, &00, &0C, &09, &00, &00, &00, &03, &00 | |
| ; Data of sprite &02: 4 bytes x 12 rows. | |
| 2D60 | .sprite_ranger_up_1 |
| EQUB &00, &03, &02, &00, &00, &00, &01, &00, &00, &00, &00, &0A, &05, &00, &03, &0A, &05, &00, &03, &09, &04, &05, &03, &09, &0C, &25, &34, &09, &1C, &0F, &1E, &09, &04, &3C, &28, &08, &04, &3C, &0C, &00, &01, &0C, &08, &00, &01, &02, &00, &00 | |
| ; Data of sprite &03: 4 bytes x 12 rows. | |
| 2D90 | .sprite_ranger_right_0 |
| EQUB &00, &04, &0B, &00, &00, &0C, &0B, &00, &04, &09, &02, &02, &04, &3C, &02, &03, &14, &1A, &02, &01, &3C, &0F, &0A, &01, &3C, &0F, &0A, &0D, &16, &1A, &04, &0D, &03, &3C, &0C, &03, &03, &06, &08, &02, &00, &00, &01, &00, &00, &00, &01, &00 | |
| ; Data of sprite &04: 4 bytes x 12 rows. | |
| 2DC0 | .sprite_ranger_right_1 |
| EQUB &00, &00, &08, &00, &00, &0C, &0D, &00, &06, &0C, &05, &00, &06, &3C, &00, &00, &16, &1A, &00, &01, &3C, &0F, &0A, &01, &3C, &0F, &0A, &01, &14, &1A, &03, &01, &00, &3C, &09, &03, &00, &0C, &0D, &02, &00, &04, &07, &02, &00, &03, &02, &00 | |
| ; Data of sprite &05: 4 bytes x 12 rows. | |
| 2DF0 | .sprite_ranger_down_0 |
| EQUB &00, &03, &00, &00, &00, &06, &0C, &00, &00, &0C, &3C, &08, &04, &16, &3C, &08, &04, &2D, &0F, &2C, &04, &38, &1A, &2C, &04, &00, &0B, &07, &04, &00, &01, &07, &00, &08, &01, &02, &02, &08, &00, &01, &01, &05, &00, &02, &00, &07, &03, &00 | |
| ; Data of sprite &06: 4 bytes x 12 rows. | |
| 2E20 | .sprite_ranger_down_1 |
| EQUB &00, &00, &01, &02, &00, &04, &0C, &02, &00, &0C, &3C, &08, &04, &14, &3C, &08, &06, &2D, &0F, &2C, &06, &38, &1A, &0C, &06, &03, &0A, &08, &06, &03, &00, &0A, &05, &03, &00, &0A, &05, &00, &00, &00, &00, &02, &00, &00, &00, &01, &03, &00 | |
| ; Data of sprite &07: 4 bytes x 12 rows. | |
| 2E50 | .sprite_ranger_left_0 |
| EQUB &00, &02, &00, &00, &00, &02, &00, &00, &01, &04, &09, &03, &03, &0C, &3C, &03, &0E, &08, &25, &29, &0E, &05, &0F, &3C, &02, &05, &0F, &3C, &02, &01, &25, &28, &03, &01, &3C, &08, &01, &01, &06, &08, &00, &07, &0C, &00, &00, &07, &08, &00 | |
| ; Data of sprite &09: 4 bytes x 12 rows. | |
| 2E80 | .sprite_monster_up_0 |
| EQUB &00, &00, &00, &02, &00, &00, &01, &13, &04, &08, &01, &13, &45, &30, &8B, &13, &10, &30, &20, &02, &1A, &30, &20, &02, &1A, &30, &25, &07, &1E, &30, &2D, &0F, &3C, &3C, &2D, &0A, &14, &3C, &2C, &00, &00, &00, &0C, &00, &00, &00, &0C, &00 | |
| ; Data of sprite &0A: 4 bytes x 12 rows. | |
| 2EB0 | .sprite_monster_up_1 |
| EQUB &00, &04, &08, &00, &00, &04, &08, &02, &45, &30, &8B, &13, &10, &30, &21, &13, &10, &30, &21, &13, &1A, &30, &20, &02, &0F, &30, &00, &02, &1E, &3C, &2D, &07, &1E, &3C, &2D, &0F, &14, &3C, &2D, &0A, &04, &08, &00, &00, &04, &08, &00, &00 | |
| ; Data of sprite &0B: 4 bytes x 12 rows. | |
| 2EE0 | .sprite_monster_right_0 |
| EQUB &00, &2D, &0A, &00, &14, &2D, &00, &00, &14, &38, &8E, &08, &14, &30, &24, &08, &14, &30, &24, &08, &14, &30, &20, &00, &1C, &30, &20, &00, &1C, &38, &8A, &00, &0C, &28, &00, &00, &00, &3C, &01, &02, &00, &0F, &03, &03, &00, &0F, &11, &22 | |
| ; Data of sprite &0C: 4 bytes x 12 rows. | |
| 2F10 | .sprite_monster_right_1 |
| EQUB &00, &2D, &0A, &00, &14, &2D, &00, &00, &1C, &38, &8A, &00, &1C, &30, &20, &00, &1C, &30, &20, &00, &14, &30, &24, &08, &3C, &30, &24, &08, &3C, &10, &8E, &08, &0F, &00, &00, &00, &0F, &01, &02, &00, &0B, &03, &03, &00, &00, &11, &22, &00 | |
| ; Data of sprite &0D: 4 bytes x 12 rows. | |
| 2F40 | .sprite_monster_down_0 |
| EQUB &00, &0C, &00, &00, &00, &0C, &00, &00, &00, &1C, &3C, &28, &05, &1E, &3C, &3C, &0F, &1E, &30, &2D, &0B, &1A, &30, &25, &01, &10, &30, &25, &01, &10, &30, &20, &23, &47, &30, &8A, &23, &02, &04, &08, &23, &02, &00, &00, &01, &00, &00, &00 | |
| ; Data of sprite &0E: 4 bytes x 12 rows. | |
| 2F70 | .sprite_monster_down_1 |
| EQUB &00, &00, &04, &08, &00, &00, &04, &08, &05, &1E, &3C, &28, &0F, &1E, &3C, &2D, &0B, &1E, &3C, &2D, &01, &00, &30, &0F, &01, &10, &30, &25, &23, &12, &30, &20, &23, &12, &30, &20, &23, &47, &30, &8A, &01, &04, &08, &00, &00, &04, &08, &00 | |
| ; Data of sprite &0F: 4 bytes x 12 rows. | |
| 2FA0 | .sprite_monster_left_0 |
| EQUB &11, &22, &0F, &00, &03, &03, &0F, &00, &01, &02, &3C, &00, &00, &00, &14, &0C, &00, &45, &34, &2C, &00, &10, &30, &2C, &00, &10, &30, &28, &04, &18, &30, &28, &04, &18, &30, &28, &04, &4D, &34, &28, &00, &00, &1E, &28, &00, &05, &1E, &00 | |
| ; Data of sprite &10: 4 bytes x 12 rows. | |
| 2FD0 | .sprite_monster_left_1 |
| EQUB &00, &11, &22, &00, &00, &03, &03, &07, &00, &01, &02, &0F, &00, &00, &00, &0F, &04, &4D, &20, &3C, &04, &18, &30, &3C, &04, &18, &30, &28, &00, &10, &30, &2C, &00, &10, &30, &2C, &00, &45, &34, &2C, &00, &00, &1E, &28, &00, &05, &1E, &00 | |
Move the heroesLet each of the four heroes, in turn from the Ranger, walk, fire or cast magic for this frame, redraw them, and let them pick up what lies in their cell. update_game calls this first in every frame, before the door and key tests (which use the cells it records in hero_door_x/y), draw_objects, move_missiles and update_monsters. A hero out of play is passed over if nobody plays them (step &63), or handed to animate_absent_hero if dying or returning through a Cross. A hero half way through a step (step 1) finishes it through continue_hero_step and reads no keys. Otherwise heroes 0 and 1 first go through check_magic, which comes back to read_hero_keys, or after a cast to draw_moved_hero with no move; then the first held of up, down, right, left and fire decides. A direction turns the hero that way (directions 1, 3, 5, 7) and tries the next cell, which is recorded in hero_door_x/y whatever is there, so a hero pushing on a door opens it. A wall or closed door, a monster (alive or dying, found by find_creature) or another hero in play refuses the move; walking into a monster also costs one health point, whatever the hero's armour. A move into another room is made at once and switches the hero's view (show_hero_room); within a room the Boots of Speed make it at once too, and without them the hero stays in the old cell, drawn half a cell along, and arrives on the next frame. Fire puts a missile in the first of the hero's free slots (3 x hero up to hero_max_missiles of them), in the hero's own cell, with bit 7 of its direction set so move_missiles does not erase it off the hero; the bell (VDU 7) sounds and the hero's frame flips. With no slot free, or no key held, the hero stands still. A hero who moved or was refused is erased from where they were drawn, using previous_x/y and previous_offset_x/y; every hero still in play is then drawn, and collect_objects runs whenever object_free_map lets their cell hold an object, every frame they are there and not only on arrival. check_magic's delay returns from move_heroes itself, so after a cast the later heroes are not moved for three frames. The bytes at &6F6D are never executed.
|
||||||||
| 6E80 | .move_heroes←1← 1CC0 JSR | |||||||
| LDX #0 ; Hero 0, the Ranger, first | ||||||||
| ; For hero X: one out of play is not moved or drawn here, only ; animated if dying or returning. | ||||||||
| 6E82 | .move_hero←1← 70C6 JMP | |||||||
| LDA hero_direction,x ; A direction (1, 3, 5, 7) means the hero is in play | ||||||||
| 6E85 | BNE remember_hero_position ; In play: remember where they are, then move them | |||||||
| 6E87 | LDA hero_step,x ; Out of play: why? The step says | |||||||
| 6E8A | CMP #step_out_of_play ; Step &63 marks a hero nobody plays | |||||||
| 6E8C | BNE animate_absent ; Not &63: the hero is dying or returning | |||||||
| 6E8E | JMP next_hero ; Nobody plays them: nothing to move or draw | |||||||
| 6E91 | .animate_absent←1← 6E8C BNE | |||||||
| JSR animate_absent_hero ; Step the skull or resurrection animation | ||||||||
| 6E94 | JMP next_hero ; Then on to the next hero | |||||||
| ; In play: keep the cell and offsets now drawn, to erase the ; hero there and to put them back if blocked. | ||||||||
| 6E97 | .remember_hero_position←1← 6E85 BNE | |||||||
| LDA hero_x,x ; Remember the hero's cell and offsets before moving | ||||||||
| 6E9A | STA previous_x ; previous_x: where to put the hero back if blocked | |||||||
| 6E9D | LDA hero_y,x ; The cell's y... | |||||||
| 6EA0 | STA previous_y ; ...in previous_y, for the same | |||||||
| 6EA3 | LDA hero_offset_x,x ; The horizontal pixel offset now drawn... | |||||||
| 6EA6 | STA previous_offset_x ; ...so erase_hero blanks the image where it is | |||||||
| 6EA9 | LDA hero_offset_y,x ; And the vertical pixel offset... | |||||||
| 6EAC | STA previous_offset_y ; ...for the same erase | |||||||
| ; A hero half way through a step arrives this frame and reads no ; keys; only a standing hero acts. | ||||||||
| 6EAF | LDA hero_step,x ; Half way between cells (step 1)? | |||||||
| 6EB2 | BEQ check_magic_key ; No: standing in a cell, so read the keys | |||||||
| 6EB4 | JSR continue_hero_step ; Yes: arrive in the next cell; no keys this frame | |||||||
| 6EB7 | JMP erase_hero ; Erase the half-way image, draw the arrival | |||||||
| 6EBA | .check_magic_key←1← 6EB2 BEQ | |||||||
| CPX #2 ; Hero 0 or 1 (the two with magic)? | ||||||||
| 6EBC | BCS read_hero_keys ; Barbarian or Fighter: no magic, straight to the keys | |||||||
| 6EBE | JMP check_magic ; Ranger or Magic-User: magic key, then back | |||||||
| ; Standing in a cell: the first held key of up, down, right, ; left and fire decides what the hero does. | ||||||||
| 6EC1 | .read_hero_keys←2← 6EBC BCS← 76AB JMP | |||||||
| LDA hero_key_up,x ; Up key held? (directions beat fire, up first) | ||||||||
| 6EC4 | JSR test_key ; Z set if held | |||||||
| 6EC7 | BNE check_key_down ; Not held: try down | |||||||
| 6EC9 | LDA #1 ; Held: face up... | |||||||
| 6ECB | STA hero_direction,x ; ...direction 1: drawn as sprite base + 1 or + 2 | |||||||
| 6ECE | JSR start_hero_step ; ...set the half-cell offsets for the step... | |||||||
| 6ED1 | JMP step_hero ; ...and try the cell above | |||||||
| 6ED4 | .check_key_down←1← 6EC7 BNE | |||||||
| LDA hero_key_down,x ; Down key held? | ||||||||
| 6ED7 | JSR test_key ; Z set if held | |||||||
| 6EDA | BNE check_key_right ; Not held: try right | |||||||
| 6EDC | LDA #5 ; Held: face down... | |||||||
| 6EDE | STA hero_direction,x ; ...direction 5: drawn as sprite base + 5 or + 6 | |||||||
| 6EE1 | JSR start_hero_step ; ...set the half-cell offsets for the step... | |||||||
| 6EE4 | JMP step_hero ; ...and try the cell below | |||||||
| 6EE7 | .check_key_right←1← 6EDA BNE | |||||||
| LDA hero_key_right,x ; Right key held? | ||||||||
| 6EEA | JSR test_key ; Z set if held | |||||||
| 6EED | BNE check_key_left ; Not held: try left | |||||||
| 6EEF | LDA #3 ; Held: face right... | |||||||
| 6EF1 | STA hero_direction,x ; ...direction 3: drawn as sprite base + 3 or + 4 | |||||||
| 6EF4 | JSR start_hero_step ; ...set the half-cell offsets for the step... | |||||||
| 6EF7 | JMP step_hero ; ...and try the cell to the right | |||||||
| 6EFA | .check_key_left←1← 6EED BNE | |||||||
| LDA hero_key_left,x ; Left key held? | ||||||||
| 6EFD | JSR test_key ; Z set if held | |||||||
| 6F00 | BNE check_key_fire ; Not held: try fire | |||||||
| 6F02 | LDA #7 ; Held: face left... | |||||||
| 6F04 | STA hero_direction,x ; ...direction 7: drawn as sprite base + 7 or + 8 | |||||||
| 6F07 | JSR start_hero_step ; ...set the half-cell offsets for the step... | |||||||
| 6F0A | JMP step_hero ; ...and try the cell to the left | |||||||
| 6F0D | .check_key_fire←1← 6F00 BNE | |||||||
| LDA hero_key_fire,x ; Fire key held? (only when no direction is) | ||||||||
| 6F10 | JSR test_key ; Z set if held | |||||||
| 6F13 | BEQ fire_missile ; Held: launch a missile the way the hero faces | |||||||
| 6F15 | JMP draw_moved_hero ; No key: the hero stands still, drawn in place | |||||||
| ; Fire: put a missile in the hero's first free slot, in the ; hero's cell, flying the way the hero faces. | ||||||||
| 6F18 | .fire_missile←1← 6F13 BEQ | |||||||
| TXA ; Slots 3 x hero to 3 x hero + hero_max_missiles - 1 | ||||||||
| 6F19 | STA scratch ; Hero number kept to add... | |||||||
| 6F1C | ASL ; ...doubled: 2 x hero... | |||||||
| 6F1D | CLC ; ...(no carry in)... | |||||||
| 6F1E | ADC scratch ; ...+ hero: 3 x hero, the hero's first slot | |||||||
| 6F21 | TAY ; Y walks the hero's slots | |||||||
| 6F22 | ADC hero_max_missiles,x ; + how many missiles the hero may have in flight... | |||||||
| 6F25 | STA scratch ; ...the first slot past the hero's own | |||||||
| 6F28 | .find_missile_slot←1← 6F74 BNE | |||||||
| LDA missile_direction,y ; This slot's missile still flying? | ||||||||
| 6F2B | BNE next_missile_slot ; Yes: look at the hero's next slot | |||||||
| 6F2D | LDA hero_direction,x ; Free: missile direction = (hero direction + 1) / 2 | |||||||
| 6F30 | CLC ; Hero direction 1, 3, 5 or 7... | |||||||
| 6F31 | ADC #1 ; ...+ 1: 2, 4, 6 or 8... | |||||||
| 6F33 | LSR ; ...halved: 1-4, up, right, down, left | |||||||
| 6F34 | ORA #&80 ; Bit 7: just fired, so not erased off the hero | |||||||
| 6F36 | STA missile_direction,y ; The slot is now in flight | |||||||
| 6F39 | LDA hero_x,x ; It starts in the hero's cell; move_missiles moves it on | |||||||
| 6F3C | STA missile_x,y ; ...missile x = hero x... | |||||||
| 6F3F | LDA hero_y,x ; ...and the hero's y... | |||||||
| 6F42 | STA missile_y,y ; ...as missile y | |||||||
| 6F45 | LDA #7 ; The firing sound: VDU 7, the bell... | |||||||
| 6F47 | JSR oswrch ; ...through OSWRCH, the same for every hero | |||||||
| 6F4A | LDA hero_missile_damage,x ; The hero's current missile damage... | |||||||
| 6F4D | STA missile_damage,y ; ...goes with this missile, for whatever it hits | |||||||
| 6F50 | LDA hero_missile_sprites,x ; The hero's weapon sprites (arrow, fireball, axe, sword)... | |||||||
| 6F53 | STA missile_sprite_base,y ; ...so it is drawn, and its owner known, by these | |||||||
| 6F56 | LDA previous_x ; Put back the cell remembered at the start... | |||||||
| 6F59 | STA hero_x,x ; ...the same cell: nothing has moved the hero here | |||||||
| 6F5C | LDA previous_y ; And the y... | |||||||
| 6F5F | STA hero_y,x ; ...is put back the same way | |||||||
| 6F62 | LDA hero_frame,x ; Next animation frame... | |||||||
| 6F65 | EOR #1 ; ...0 and 1 alternate... | |||||||
| 6F67 | STA hero_frame,x ; ...so the hero is seen to throw | |||||||
| 6F6A | JMP draw_moved_hero ; Draw the hero where they stand; no erase needed | |||||||
| ; Unreachable after the JMP: DEY and BNE find_missile_slot. | ||||||||
| 6F6D | EQUB &88, &D0, &B8 ; Not referenced | |||||||
| ; Slot taken: try the hero's next one, up to the limit worked ; out above. | ||||||||
| 6F70 | .next_missile_slot←1← 6F2B BNE | |||||||
| INY ; The hero's next slot | ||||||||
| 6F71 | CPY scratch ; Past the hero's last slot? | |||||||
| 6F74 | BNE find_missile_slot ; No: is that one free? | |||||||
| 6F76 | JMP draw_moved_hero ; All the hero's missiles in flight: no shot | |||||||
| ; Move: try the next cell the way the hero faces. A wall or ; closed door, a monster, or another hero in play refuses it. ; The hero has already turned, so a refused move still changes ; the way they face. | ||||||||
| 6F79 | .step_hero←4← 6ED1 JMP← 6EE4 JMP← 6EF7 JMP← 6F0A JMP | |||||||
| LDA hero_direction,x ; Move the hero's cell in the direction faced: up... | ||||||||
| 6F7C | CMP #1 ; Direction 1, facing up? | |||||||
| 6F7E | BNE step_right ; No: try right | |||||||
| 6F80 | DEC hero_y,x ; Up: one row up the map | |||||||
| 6F83 | .step_right←1← 6F7E BNE | |||||||
| CMP #3 ; Direction 3, facing right? (A still holds it) | ||||||||
| 6F85 | BNE step_down ; No: try down | |||||||
| 6F87 | INC hero_x,x ; Right: one column along | |||||||
| 6F8A | .step_down←1← 6F85 BNE | |||||||
| CMP #5 ; Direction 5, facing down? | ||||||||
| 6F8C | BNE step_left ; No: try left | |||||||
| 6F8E | INC hero_y,x ; Down: one row down the map | |||||||
| 6F91 | .step_left←1← 6F8C BNE | |||||||
| CMP #7 ; Direction 7, facing left? | ||||||||
| 6F93 | BNE note_new_cell ; No: the cell is moved | |||||||
| 6F95 | DEC hero_x,x ; Left: one column back | |||||||
| 6F98 | .note_new_cell←1← 6F93 BNE | |||||||
| LDA hero_x,x ; Record the cell tried, wall or not... | ||||||||
| 6F9B | STA hero_door_x,x ; ...so update_game finds a door the hero walks into | |||||||
| 6F9E | LDA hero_y,x ; And the y tried... | |||||||
| 6FA1 | STA hero_door_y,x ; ...in hero_door_y, for the same door test | |||||||
| 6FA4 | LDA hero_x,x ; Is the cell tried a wall (or a closed door)? | |||||||
| 6FA7 | STA cell_x ; cell_x: the cell for test_wall | |||||||
| 6FAA | LDA hero_y,x ; And the y tried... | |||||||
| 6FAD | STA cell_y ; ...in cell_y, also used by the hero test | |||||||
| 6FB0 | TXA ; Keep the hero number... | |||||||
| 6FB1 | PHA ; ...on the stack across test_wall | |||||||
| 6FB2 | JSR test_wall ; Y = the cell's wall bit; map_ptr = its room | |||||||
| 6FB5 | PLA ; Recover the hero number... | |||||||
| 6FB6 | TAX ; ...into X, which test_wall used for the bit | |||||||
| 6FB7 | CPY #0 ; Wall bit clear? | |||||||
| 6FB9 | BEQ check_monster_in_cell ; Clear: is a monster in the way? | |||||||
| ; Refused by a wall or closed door: back to the old cell, ; standing whole. The door test in update_game may still open ; it. | ||||||||
| 6FBB | LDA previous_x ; A wall: the hero stays in the old cell... | |||||||
| 6FBE | STA hero_x,x ; ...hero_x put back from previous_x... | |||||||
| 6FC1 | LDA previous_y ; ...and y back... | |||||||
| 6FC4 | STA hero_y,x ; ...so the hero does not enter the wall | |||||||
| 6FC7 | .cancel_hero_step←1← 7050 JMP | |||||||
| LDA #0 ; The move is over: the hero stands in a whole cell | ||||||||
| 6FC9 | STA hero_step,x ; No step under way... | |||||||
| 6FCC | STA hero_offset_x,x ; ...no horizontal offset... | |||||||
| 6FCF | STA hero_offset_y,x ; ...and no vertical offset | |||||||
| 6FD2 | JMP erase_hero ; Erase the old image, draw the hero in their cell | |||||||
| ; No wall. A monster in the cell, alive or dying, refuses the ; move and costs the hero one health point. | ||||||||
| 6FD5 | .check_monster_in_cell←1← 6FB9 BEQ | |||||||
| LDA #0 ; Is a monster in the cell tried? | ||||||||
| 6FD7 | STA scratch ; scratch 0: look for monsters only, not heroes | |||||||
| 6FDA | TXA ; Keep the hero number... | |||||||
| 6FDB | PHA ; ...on the stack across find_creature | |||||||
| 6FDC | JSR find_creature ; Y non-zero if a monster is in the cell | |||||||
| 6FDF | PLA ; Recover the hero number... | |||||||
| 6FE0 | TAX ; ...into X, which find_creature used for monsters | |||||||
| 6FE1 | CPY #0 ; A monster there? | |||||||
| 6FE3 | BEQ check_hero_in_cell ; No: is another hero in the way? | |||||||
| 6FE5 | LDA previous_x ; Yes: the hero stays in the old cell... | |||||||
| 6FE8 | STA hero_x,x ; ...hero_x put back from previous_x... | |||||||
| 6FEB | LDA previous_y ; ...and y back... | |||||||
| 6FEE | STA hero_y,x ; ...so the hero stays out of the monster's cell | |||||||
| 6FF1 | LDA #0 ; The move is over: the hero stands in a whole cell... | |||||||
| 6FF3 | STA hero_step,x ; ...no step under way... | |||||||
| 6FF6 | STA hero_offset_x,x ; ...no horizontal offset... | |||||||
| 6FF9 | STA hero_offset_y,x ; ...and no vertical offset | |||||||
| 6FFC | JSR lose_health_point ; ...and pays a health point for walking into it | |||||||
| 6FFF | JMP erase_hero ; Erase the old image, draw the hero in their cell | |||||||
| ; Nor a monster. Another hero in play there refuses the move at ; no cost; a hero out of play (a skull) does not. | ||||||||
| 7002 | .check_hero_in_cell←1← 6FE3 BEQ | |||||||
| STX scratch ; Is another hero in play in the cell tried? | ||||||||
| 7005 | LDY #0 ; From hero 0 | |||||||
| 7007 | .check_other_hero←1← 703E BNE | |||||||
| CPY scratch ; The moving hero itself? | ||||||||
| 700A | BEQ next_other_hero ; Yes: skip it | |||||||
| 700C | LDA hero_x,y ; Other hero's x... | |||||||
| 700F | CMP cell_x ; ...the cell tried's x? | |||||||
| 7012 | BNE next_other_hero ; No: not in the way | |||||||
| 7014 | LDA hero_y,y ; Other hero's y... | |||||||
| 7017 | CMP cell_y ; ...the cell tried's y? | |||||||
| 701A | BNE next_other_hero ; No: not in the way | |||||||
| 701C | LDA hero_direction,y ; There, but in play? | |||||||
| 701F | BEQ next_other_hero ; No (a skull, say): not in the way | |||||||
| 7021 | LDA previous_x ; In play there: the hero stays in the old cell... | |||||||
| 7024 | STA hero_x,x ; ...hero_x put back from previous_x... | |||||||
| 7027 | LDA previous_y ; ...and y back... | |||||||
| 702A | STA hero_y,x ; ...so heroes in play never share a cell | |||||||
| 702D | LDA #0 ; The move is over: the hero stands in a whole cell... | |||||||
| 702F | STA hero_step,x ; ...no step under way... | |||||||
| 7032 | STA hero_offset_x,x ; ...no horizontal offset... | |||||||
| 7035 | STA hero_offset_y,x ; ...and no vertical offset | |||||||
| 7038 | JMP erase_hero ; Erase the old image, draw the hero in their cell | |||||||
| 703B | .next_other_hero←4← 700A BEQ← 7012 BNE← 701A BNE← 701F BEQ | |||||||
| INY ; Next hero to compare with the cell tried | ||||||||
| 703C | CPY #4 ; Checked all four? | |||||||
| 703E | BNE check_other_hero ; No: check that one | |||||||
| ; The cell is free. A move into another room is made at once, as ; is one with the Boots of Speed; otherwise the hero is drawn ; half way and arrives on the next frame. | ||||||||
| 7040 | TXA ; The way is clear. Is the cell tried in another room? | |||||||
| 7041 | ASL ; Two bytes per view_room entry... | |||||||
| 7042 | TAX ; ...so X = 2 x hero indexes the hero's view | |||||||
| 7043 | LDA view_room,x ; The low byte of the room the hero's view shows... | |||||||
| 7046 | CMP map_ptr ; ...against the cell's room, left by test_wall | |||||||
| 7048 | BEQ check_boots ; Same room: the boots decide the pace | |||||||
| 704A | TXA ; New room: the hero arrives at once... | |||||||
| 704B | LSR ; Halve the index... | |||||||
| 704C | TAX ; ...back to the hero number | |||||||
| 704D | JSR show_hero_room ; Switch the hero's view to the new room and draw it | |||||||
| 7050 | JMP cancel_hero_step ; ...and the move ends in the new cell, no half step | |||||||
| 7053 | .check_boots←1← 7048 BEQ | |||||||
| TXA ; Wearing the Boots of Speed? | ||||||||
| 7054 | LSR ; Halve the view index... | |||||||
| 7055 | TAX ; ...back to the hero number | |||||||
| 7056 | LDA hero_has_boots,x ; Non-zero while the hero wears the boots | |||||||
| 7059 | BEQ stay_in_old_cell ; No: a half step this frame | |||||||
| 705B | LDA #0 ; Yes: arrive in the cell at once, with no step | |||||||
| 705D | STA hero_offset_x,x ; No horizontal offset... | |||||||
| 7060 | STA hero_offset_y,x ; ...no vertical offset... | |||||||
| 7063 | STA hero_step,x ; ...and no step: one cell a frame, twice the pace | |||||||
| 7066 | JMP erase_hero ; Erase the old position and draw the new | |||||||
| 7069 | .stay_in_old_cell←1← 7059 BEQ | |||||||
| LDA previous_x ; No boots: hero stays in the old cell, drawn half way | ||||||||
| 706C | STA hero_x,x ; ...by start_hero_step's offsets; next frame it arrives | |||||||
| 706F | LDA previous_y ; And the old y... | |||||||
| 7072 | STA hero_y,x ; ...so others still meet the hero in the old cell | |||||||
| ; Erase the hero's image from where it was drawn last. | ||||||||
| 7075 | .erase_hero←5← 6EB7 JMP← 6FD2 JMP← 6FFF JMP← 7038 JMP← 7066 JMP | |||||||
| LDA #spr_blank ; Erase the hero's image as it was before this frame | ||||||||
| 7077 | STA sprite_number ; The blank sprite... | |||||||
| 7079 | LDA previous_x ; ...at the hero's old cell... | |||||||
| 707C | STA cell_x ; ...as the cell to plot at | |||||||
| 707F | LDA previous_y ; And the old y... | |||||||
| 7082 | STA cell_y ; ...in cell_y: where the hero was last drawn | |||||||
| 7085 | LDA previous_offset_x ; With the old pixel offsets too... | |||||||
| 7088 | STA plot_offset_x ; ...the old horizontal offset... | |||||||
| 708A | LDA previous_offset_y ; ...and the old vertical offset... | |||||||
| 708D | STA plot_offset_y ; ...so a half-way image is blanked where it was | |||||||
| 708F | TXA ; Keep the hero number... | |||||||
| 7090 | PHA ; ...on the stack across plot_at_cell | |||||||
| 7091 | JSR plot_at_cell ; Blank the hero in every view showing that cell | |||||||
| 7094 | PLA ; Recover the hero number... | |||||||
| 7095 | TAX ; ...into X, to draw the same hero | |||||||
| ; Draw the hero, then pick up any object in their cell. A hero ; comes here on every frame they are moved, standing still or ; not, so a hero standing on an energy drainer loses 10 health a ; frame. | ||||||||
| 7096 | .draw_moved_hero←4← 6F15 JMP← 6F6A JMP← 6F76 JMP← 76AE JMP | |||||||
| CLC ; Clear carry for the sprite sum | ||||||||
| 7097 | LDA hero_direction,x ; Still in play? A bump or magic's cost may have killed | |||||||
| 709A | BEQ next_hero ; Direction 0: out of play, not drawn | |||||||
| 709C | ADC hero_frame,x ; Sprite = direction + frame (0 or 1)... | |||||||
| 709F | ADC hero_sprites,x ; ...+ the hero's base: Ranger, Magic-User, and so on | |||||||
| 70A2 | STA sprite_number ; The sprite to draw | |||||||
| 70A4 | JSR draw_hero ; Draw them in every view showing their cell | |||||||
| 70A7 | LDA hero_x,x ; Can the hero's cell hold an object? | |||||||
| 70AA | STA cell_x ; The hero's cell, to test for an object... | |||||||
| 70AD | LDA hero_y,x ; And the hero's y... | |||||||
| 70B0 | STA cell_y ; ...in cell_y, where they now stand | |||||||
| 70B3 | TXA ; Keep the hero number... | |||||||
| 70B4 | PHA ; ...on the stack across test_object_free | |||||||
| 70B5 | JSR test_object_free ; Y zero if an object may lie in the cell | |||||||
| 70B8 | PLA ; Recover the hero number... | |||||||
| 70B9 | TAX ; ...into X, for collect_objects | |||||||
| 70BA | CPY #0 ; Can an object lie there? | |||||||
| 70BC | BNE next_hero ; No: nothing to pick up; next hero | |||||||
| 70BE | JSR collect_objects ; Yes: pick up whatever is there | |||||||
| ; On to the next hero, until all four have had their turn. | ||||||||
| 70C1 | .next_hero←4← 6E8E JMP← 6E94 JMP← 709A BEQ← 70BC BNE | |||||||
| INX ; Next hero, in the order Ranger to Fighter | ||||||||
| 70C2 | CPX #4 ; All four heroes moved? | |||||||
| 70C4 | BEQ move_heroes_done ; Yes: every hero has had this frame's turn | |||||||
| 70C6 | JMP move_hero ; No: move the next hero | |||||||
| 70C9 | .move_heroes_done←1← 70C4 BEQ | |||||||
| RTS ; Return to update_game, all four heroes moved and drawn | ||||||||
Move the missilesFly every missile in flight one cell and settle what it hits. update_game calls this each frame, after move_heroes (which fires them) and draw_objects, and before update_monsters, which plays out the deaths it causes. Each of the twelve slots (three per hero, from 3 x hero) with a non-zero missile_direction is in flight. It is erased from its cell, unless fired this frame (bit 7 set) and so still on its hero, whose frame flip_firer_frame then flips back. It moves one cell in its direction (1-4: up, right, down, left), a cell a frame with no pixel offset, and the new cell is tried in turn, with the slot kept on the stack throughout. A wall spends the missile. A live monster takes its damage through monster_hit, which spends the missile and, for a kill, gives the firer a point; a monster already sparkling lets it through. The test for live is a sprite below the first sparkle, so a monster killed earlier in the frame (sprite blank until update_monsters runs) can be hit again. An energy drainer is worn down a stage, and removed after its last; the firer scores a point and the missile is turned round in the drainer's cell, so it can fly back into its firer. Any hero in the cell, the firer included and whether in play or not (a skull stops it), spends the missile, and lose_health_point takes missile_damage points, one at a time, from a hero in play. Otherwise the missile is drawn in its new cell as missile_sprite_base + direction, the weapon pointing the way it flies. A spent missile is not drawn, and its direction 0 frees the slot for its hero's next shot. Missiles pass through one another and through objects other than drainers.
|
||||||||
| 70CA | .move_missiles←1← 1ED1 JSR | |||||||
| LDA #0 ; Missiles move a whole cell a frame... | ||||||||
| 70CC | STA plot_offset_x ; ...so they are plotted with no horizontal offset... | |||||||
| 70CE | STA plot_offset_y ; ...and no vertical offset | |||||||
| 70D0 | LDX #0 ; Slot 0 first: the Ranger's first missile | |||||||
| ; For missile slot X: an empty slot (direction 0) is passed ; over. One fired this frame shares its hero's cell and is moved ; without being erased. | ||||||||
| 70D2 | .move_missile←1← 721D JMP | |||||||
| LDA missile_direction,x ; A direction means this slot's missile is flying | ||||||||
| 70D5 | BNE check_just_fired ; Flying: erase and move it | |||||||
| 70D7 | JMP next_missile ; Empty slot: nothing to move | |||||||
| 70DA | .check_just_fired←1← 70D5 BNE | |||||||
| BPL erase_missile ; Bit 7 clear: flying since an earlier frame | ||||||||
| 70DC | AND #&7f ; Fired this frame: drop the just-fired bit... | |||||||
| 70DE | STA missile_direction,x ; ...leaving direction 1-4 | |||||||
| 70E1 | JSR flip_firer_frame ; ...flip the firer's animation frame again... | |||||||
| 70E4 | JMP step_missile ; ...and move it unerased: its cell is the hero's | |||||||
| ; Erase the missile and move it one cell. | ||||||||
| 70E7 | .erase_missile←1← 70DA BPL | |||||||
| LDA #spr_blank ; Erase the missile from the cell it flew to last frame | ||||||||
| 70E9 | STA sprite_number ; The blank sprite | |||||||
| 70EB | LDA missile_x,x ; The missile's x... | |||||||
| 70EE | STA cell_x ; ...as the cell to plot at | |||||||
| 70F1 | LDA missile_y,x ; And its y... | |||||||
| 70F4 | STA cell_y ; ...in cell_y: where it was drawn last frame | |||||||
| 70F7 | TXA ; Keep the missile slot... | |||||||
| 70F8 | PHA ; ...on the stack across plot_at_cell | |||||||
| 70F9 | JSR plot_at_cell ; Blank it in every view showing that cell | |||||||
| 70FC | PLA ; Recover the missile slot... | |||||||
| 70FD | TAX ; ...into X, to move the same missile | |||||||
| 70FE | .step_missile←1← 70E4 JMP | |||||||
| LDA missile_direction,x ; Move it one cell the way it flies: up... | ||||||||
| 7101 | CMP #1 ; Direction 1: up | |||||||
| 7103 | BNE missile_right ; No: try right | |||||||
| 7105 | DEC missile_y,x ; Up: one row up the map | |||||||
| 7108 | .missile_right←1← 7103 BNE | |||||||
| CMP #2 ; Direction 2: right? (A still holds it) | ||||||||
| 710A | BNE missile_down ; No: try down | |||||||
| 710C | INC missile_x,x ; Right: one column along | |||||||
| 710F | .missile_down←1← 710A BNE | |||||||
| CMP #3 ; Direction 3: down? | ||||||||
| 7111 | BNE missile_left ; No: try left | |||||||
| 7113 | INC missile_y,x ; Down: one row down the map | |||||||
| 7116 | .missile_left←1← 7111 BNE | |||||||
| CMP #4 ; Direction 4: left? | ||||||||
| 7118 | BNE check_missile_wall ; No: the cell is moved | |||||||
| 711A | DEC missile_x,x ; Left: one column back | |||||||
| ; Try the new cell: wall, monster, energy drainer, then hero. ; The slot stays on the stack through the tests. | ||||||||
| 711D | .check_missile_wall←1← 7118 BNE | |||||||
| LDA missile_x,x ; Does the missile's new cell hold a wall or door? | ||||||||
| 7120 | STA cell_x ; ...as the cell to test | |||||||
| 7123 | LDA missile_y,x ; And its y... | |||||||
| 7126 | STA cell_y ; ...in cell_y, kept for every test below | |||||||
| 7129 | TXA ; Keep the missile slot... | |||||||
| 712A | PHA ; ...on the stack across the tests | |||||||
| 712B | JSR test_wall ; Z set if the cell is clear of walls | |||||||
| 712E | BEQ check_missile_monster ; Clear: is a monster there? | |||||||
| ; Spent: the missile stops where it is, undrawn, and its slot is ; free for its hero's next shot. | ||||||||
| 7130 | .missile_spent_pop←2← 71FE JMP← 75AB JMP | |||||||
| PLA ; A wall: the missile stops, never drawn there | ||||||||
| 7131 | TAX ; Recover the missile slot | |||||||
| 7132 | .missile_spent←1← 7153 JMP | |||||||
| LDA #0 ; The missile is spent: free its slot... | ||||||||
| 7134 | STA missile_direction,x ; ...direction 0, so the hero may fire again | |||||||
| 7137 | JMP next_missile ; On to the next slot | |||||||
| ; No wall. A live monster takes the hit; a sparkling (dying) one ; lets the missile through. | ||||||||
| 713A | .check_missile_monster←1← 712E BEQ | |||||||
| LDA #0 ; Is a monster in the new cell? | ||||||||
| 713C | STA scratch ; scratch 0: look for monsters only, not heroes | |||||||
| 713F | JSR find_creature ; Z clear, X = the monster, if one is in the cell | |||||||
| 7142 | BEQ check_missile_object ; None: an object or a hero? | |||||||
| 7144 | LDA monster_sprite,x ; One there: is it still alive? | |||||||
| 7147 | CMP #spr_sparkle_0 ; Sparkles on: dying; the blank (just killed) is live | |||||||
| 7149 | BCS check_missile_object ; Dying: the missile flies through it | |||||||
| 714B | PLA ; Alive: hit it, with the slot off the stack... | |||||||
| 714C | TAY ; ...in Y, for monster_hit | |||||||
| 714D | JMP monster_hit ; Hit sound, damage; it spends the missile | |||||||
| ; monster_hit jumps back here, slot in X, when its hit kills the ; monster. | ||||||||
| 7150 | .monster_killed←1← 75A3 JMP | |||||||
| JSR credit_missile_owner ; monster_hit's kill: a point to the firer... | ||||||||
| 7153 | JMP missile_spent ; ...and the missile is spent | |||||||
| ; No live monster there. If the cell can hold an object, look ; for an energy drainer there. | ||||||||
| 7156 | .check_missile_object←2← 7142 BEQ← 7149 BCS | |||||||
| PLA ; Could the new cell hold an object (a drainer)? | ||||||||
| 7157 | TAX ; Recover the missile slot | |||||||
| 7158 | LDA missile_x,x ; The missile's x... | |||||||
| 715B | STA cell_x ; ...as the cell to test | |||||||
| 715E | LDA missile_y,x ; And its y... | |||||||
| 7161 | STA cell_y ; ...in cell_y (find_creature left it intact) | |||||||
| 7164 | TXA ; Keep the missile slot... | |||||||
| 7165 | PHA ; ...on the stack across test_object_free | |||||||
| 7166 | JSR test_object_free ; Y zero if an object may lie in the cell | |||||||
| 7169 | PLA ; Recover the missile slot... | |||||||
| 716A | TAX ; ...into X, which test_object_free used for the bit | |||||||
| 716B | CPY #0 ; Can an object lie there? | |||||||
| 716D | BNE check_missile_hero ; No: no drainer; is a hero there? | |||||||
| ; A missile hitting an energy drainer wears it down, scores for ; the firer and turns round in its cell. | ||||||||
| 716F | TXA ; Look for an energy drainer at the cell... | |||||||
| 7170 | PHA ; Keep the missile slot while X runs over objects | |||||||
| 7171 | LDX #max_object ; ...objects 30 to 1 | |||||||
| 7173 | .check_object_drainer←1← 71D5 BNE | |||||||
| LDA object_x,x ; This object's x... | ||||||||
| 7176 | CMP cell_x ; ...the missile's cell? | |||||||
| 7179 | BNE next_object_drainer ; No: the next object | |||||||
| 717B | LDA object_y,x ; This object's y... | |||||||
| 717E | CMP cell_y ; ...the missile's cell too? | |||||||
| 7181 | BNE next_object_drainer ; No: the next object | |||||||
| 7183 | LDA object_type,x ; The object in the cell: a drainer (&53-&5E)? | |||||||
| 7186 | CMP #spr_drainer_0 ; Below the drainer sprites? | |||||||
| 7188 | BCC no_drainer ; Yes: some other object; stop looking | |||||||
| 718A | CMP #spr_drainer_11 + 1 ; Past the last drainer stage? | |||||||
| 718C | BCS no_drainer ; Yes: some other object; stop looking | |||||||
| 718E | INC object_type,x ; A drainer: the hit wears it down a stage | |||||||
| 7191 | LDA object_type,x ; Its new stage... | |||||||
| 7194 | CMP #spr_drainer_11 + 1 ; Past the last (12 hits from the first stage)? | |||||||
| 7196 | BNE credit_drainer_hit ; No: it survives; score and bounce | |||||||
| 7198 | LDA #off_map ; Worn away: take it out of the level | |||||||
| 719A | STA object_x,x ; Off the map in x... | |||||||
| 719D | STA object_y,x ; ...and y, so it is never drawn or met again | |||||||
| 71A0 | .credit_drainer_hit←1← 7196 BNE | |||||||
| PLA ; A point to the hero who fired, for every hit | ||||||||
| 71A1 | TAX ; Recover the missile slot | |||||||
| 71A2 | JSR credit_missile_owner ; The missile's sprites say whose it is | |||||||
| 71A5 | LDA missile_direction,x ; Turn the missile round, still in the drainer's cell | |||||||
| 71A8 | CMP #1 ; Direction 1, flying up? | |||||||
| 71AA | BNE reverse_right ; No: try right | |||||||
| 71AC | LDA #3 ; Up turns to down... | |||||||
| 71AE | STA missile_direction,x ; ...back the way it came | |||||||
| 71B1 | JMP check_missile_hero ; Is a hero in the drainer's cell? | |||||||
| 71B4 | .reverse_right←1← 71AA BNE | |||||||
| CMP #2 ; Direction 2, flying right? | ||||||||
| 71B6 | BNE reverse_down ; No: try down | |||||||
| 71B8 | LDA #4 ; Right turns to left... | |||||||
| 71BA | STA missile_direction,x ; ...back the way it came | |||||||
| 71BD | JMP check_missile_hero ; Is a hero in the drainer's cell? | |||||||
| 71C0 | .reverse_down←1← 71B6 BNE | |||||||
| CMP #3 ; Direction 3, flying down? | ||||||||
| 71C2 | BNE reverse_left ; No: it was flying left | |||||||
| 71C4 | LDA #1 ; Down turns to up... | |||||||
| 71C6 | STA missile_direction,x ; ...back the way it came | |||||||
| 71C9 | JMP check_missile_hero ; Is a hero in the drainer's cell? | |||||||
| 71CC | .reverse_left←1← 71C2 BNE | |||||||
| LDA #2 ; Left turns to right... | ||||||||
| 71CE | STA missile_direction,x ; ...back the way it came | |||||||
| 71D1 | JMP check_missile_hero ; Is a hero in the drainer's cell? | |||||||
| 71D4 | .next_object_drainer←2← 7179 BNE← 7181 BNE | |||||||
| DEX ; Next object down, looking for one in the cell | ||||||||
| 71D5 | BNE check_object_drainer ; Until all 30 are checked | |||||||
| 71D7 | .no_drainer←2← 7188 BCC← 718C BCS | |||||||
| PLA ; No drainer in the cell: drop the saved slot... | ||||||||
| 71D8 | TAX ; ...back into X | |||||||
| ; The first hero in the cell, in play or not, stops the missile. | ||||||||
| 71D9 | .check_missile_hero←5← 716D BNE← 71B1 JMP← 71BD JMP← 71C9 JMP← 71D1 JMP | |||||||
| TXA ; Is a hero in the new cell? Any hero, even the firer | ||||||||
| 71DA | PHA ; Keep the missile slot while X runs over heroes | |||||||
| 71DB | LDX #0 ; From hero 0 | |||||||
| 71DD | .check_hero_hit←1← 7204 BNE | |||||||
| PLA ; Fetch the missile slot... | ||||||||
| 71DE | TAY ; ...into Y, to read its damage if this hero is hit... | |||||||
| 71DF | PHA ; ...leaving it on the stack | |||||||
| 71E0 | LDA hero_x,x ; This hero's x... | |||||||
| 71E3 | CMP cell_x ; ...the missile's cell? | |||||||
| 71E6 | BNE next_hero_hit ; No: the next hero | |||||||
| 71E8 | LDA hero_y,x ; This hero's y... | |||||||
| 71EB | CMP cell_y ; ...the missile's cell too? | |||||||
| 71EE | BNE next_hero_hit ; No: the next hero | |||||||
| 71F0 | LDA missile_damage,y ; Hit: the hero loses the missile's damage... | |||||||
| 71F3 | TAY ; ...Y health points, one at a time | |||||||
| 71F4 | .take_missile_damage←1← 71FC BNE | |||||||
| TYA ; Keep the count... | ||||||||
| 71F5 | PHA ; ...on the stack across the call | |||||||
| 71F6 | JSR lose_health_point ; One point (none if out of play, as a skull) | |||||||
| 71F9 | PLA ; Recover the count... | |||||||
| 71FA | TAY ; ...of damage points still to take, into Y | |||||||
| 71FB | DEY ; One fewer to take | |||||||
| 71FC | BNE take_missile_damage ; More to take: take the next | |||||||
| 71FE | JMP missile_spent_pop ; The missile is spent, slot still on the stack | |||||||
| 7201 | .next_hero_hit←2← 71E6 BNE← 71EE BNE | |||||||
| INX ; Next hero to test against the missile's cell | ||||||||
| 7202 | CPX #4 ; All four heroes checked? | |||||||
| 7204 | BNE check_hero_hit ; No: check the next hero against the missile's cell | |||||||
| ; No wall, live monster or hero in the new cell: draw the ; missile there, pointing the way it flies (a drainer will have ; turned it round), then go on to the next slot. | ||||||||
| 7206 | PLA ; Nothing hit: the missile flies on, drawn in its new cell | |||||||
| 7207 | TAX ; Missile slot back in X | |||||||
| 7208 | CLC ; Sprite = the missile's base... | |||||||
| 7209 | LDA missile_sprite_base,x ; ...(its hero's weapon, the sprite before its up sprite)... | |||||||
| 720C | ADC missile_direction,x ; ...plus its direction, 1-4: the weapon pointing that way | |||||||
| 720F | STA sprite_number ; ...is the sprite to plot | |||||||
| 7211 | TXA ; Keep the missile slot... | |||||||
| 7212 | PHA ; ...across the plot | |||||||
| 7213 | JSR plot_at_cell ; Plot the missile in every view showing its cell | |||||||
| 7216 | PLA ; Recover the missile slot... | |||||||
| 7217 | TAX ; ...into X, for the slot loop | |||||||
| 7218 | .next_missile←2← 70D7 JMP← 7137 JMP | |||||||
| INX ; Next missile slot | ||||||||
| 7219 | CPX #&0c ; Past the twelfth slot (three per hero)? | |||||||
| 721B | BEQ move_missiles_done ; Yes: every missile moved this frame | |||||||
| 721D | JMP move_missile ; No: move this slot's missile | |||||||
| 7220 | .move_missiles_done←1← 721B BEQ | |||||||
| RTS ; Return to update_game: all twelve slots done | ||||||||
Take one health point from a heroIf hero X is in play, take one point from their health and redraw it in the status panel; if that point was their last, kill them. Every kind of harm is paid through here, one call per point: a hero walking into a monster (move_heroes, 1 point), a monster stepping onto a hero (hero_damage_taken points), a missile (its damage), an energy drainer (10, from collect_objects) and the cost of magic (6 for the Ranger, 3 for the Magic-User). Three callers use it only to draw a health they have set one point high: draw_status_panel (99 + 1 at each level), the potion, and a returning hero (33, drawn as 32). Health is two digit sprites, hero_health_tens and hero_health_units (&1E-&27 for 0-9), so the units digit wraps from 0 to 9 with a borrow from the tens. Health 00 is still alive; the hero dies when a point is taken from 00, which leaves the tens at &1D, one below the 0 sprite: the play loop tests that to count the dead. On death the hero's sprite is erased from every view, they leave play (direction 0), the death animation is started (frame step +1, counter 1, run by move_heroes) and their number + 1 is put in the first free entry of returning_hero_queue, for a Cross of Resurrection to bring back. The health is not redrawn on death. A hero out of play (dying, returning, or not playing) loses nothing, so a skull is safe to touch.
|
|||||||
| 7221 | .lose_health_point←8← 0EFF JSR← 6FFC JSR← 71F6 JSR← 749A JSR← 7512 JSR← 7654 JSR← 772A JSR← 79AC JSR | ||||||
| LDA hero_direction,x ; Direction 0: out of play, dying or returning | |||||||
| 7224 | BNE take_health_unit ; In play: they can be hurt | ||||||
| 7226 | RTS ; Out of play: nothing to lose | ||||||
| 7227 | .take_health_unit←1← 7224 BNE | ||||||
| DEC hero_health_units,x ; Health down one: the units digit sprite | |||||||
| 722A | LDA hero_health_units,x ; ...and look at the new units digit | ||||||
| 722D | CMP #spr_digit_0 - 1 ; Gone below the 0 sprite? | ||||||
| 722F | BNE draw_health ; No: the tens are untouched, redraw the health | ||||||
| 7231 | LDA #spr_digit_9 ; Yes: units back to 9... | ||||||
| 7233 | STA hero_health_units,x ; ...so 30 becomes 29 | ||||||
| 7236 | DEC hero_health_tens,x ; ...and borrow from the tens | ||||||
| 7239 | LDA hero_health_tens,x ; ...and look at the new tens digit | ||||||
| 723C | CMP #spr_digit_0 - 1 ; Below 0? The point was taken from 00 | ||||||
| 723E | BNE draw_health ; No: still alive, redraw the health | ||||||
| ; The point was taken from health 00: the hero dies. The tens ; digit is left at &1D, below the 0 sprite, which marks the hero ; as dead to the play loop. | |||||||
| 7240 | LDA #spr_blank ; The hero has died: erase them... | ||||||
| 7242 | STA sprite_number ; ...with the blank sprite... | ||||||
| 7244 | JSR draw_hero ; ...at their cell in every view showing it | ||||||
| 7247 | LDA #0 ; ...take them out of play... | ||||||
| 7249 | STA hero_direction,x ; ...so they neither move nor take more harm | ||||||
| 724C | LDA #1 ; ...and start the death animation: | ||||||
| 724E | STA hero_offset_x,x ; ...frame step +1: forwards to the skull... | ||||||
| 7251 | STA hero_offset_y,x ; ...frame counter 1: the first step comes next frame | ||||||
| ; Put the hero in the first free (zero) entry of ; returning_hero_queue, as hero + 1, to wait for a Cross. The ; search has no limit; a free entry is always there, as the ; queue holds at most one entry per hero. | |||||||
| 7254 | LDY #0 ; Queue them for a Cross: from the queue's front... | ||||||
| 7256 | .find_queue_slot←1← 7264 BNE | ||||||
| LDA returning_hero_queue,y ; ...look at this queue entry | |||||||
| 7259 | BNE next_queue_slot ; Taken: try the next entry | ||||||
| 725B | TXA ; Free: entry = hero number + 1... | ||||||
| 725C | CLC ; ...(carry clear for the add)... | ||||||
| 725D | ADC #1 ; ...(entries are hero + 1, so 0 can mean free)... | ||||||
| 725F | STA returning_hero_queue,y ; ...queued behind those already waiting | ||||||
| 7262 | RTS ; Return, health not redrawn | ||||||
| 7263 | .next_queue_slot←1← 7259 BNE | ||||||
| INY ; Next queue entry | |||||||
| 7264 | BNE find_queue_slot ; Keep looking (an empty entry is always found) | ||||||
| ; Draw hero X's health, two digit sprites on the top row of ; their panel section, tens at panel_left and units three byte ; columns right. lose_health_point falls through to here and ; food calls it; plot_sprite corrupts X, so the hero is kept on ; the stack. | |||||||
| 7266 | .draw_health←3← 722F BNE← 723E BNE← 73A2 JSR | ||||||
| LDA hero_panel_y,x ; Health on the top row of the hero's panel section... | |||||||
| 7269 | STA plot_y ; ...as the plotting row | ||||||
| 726B | LDA #panel_left ; Tens in the panel's left column... | ||||||
| 726D | STA plot_x ; ...as the plotting column | ||||||
| 726F | LDA hero_health_tens,x ; The tens digit sprite... | ||||||
| 7272 | STA sprite_number ; ...as the sprite to plot | ||||||
| 7274 | TXA ; Keep the hero number... | ||||||
| 7275 | PHA ; ...across the plot | ||||||
| 7276 | JSR plot_sprite ; Plot the health's tens digit | ||||||
| 7279 | PLA ; Recover the hero number... | ||||||
| 727A | TAX ; ...into X, for the units digit | ||||||
| 727B | LDA hero_health_units,x ; The units digit sprite... | ||||||
| 727E | STA sprite_number ; ...as the sprite to plot | ||||||
| 7280 | LDA #panel_left + 3 ; ...three byte columns right of the tens... | ||||||
| 7282 | STA plot_x ; ...on the same row | ||||||
| 7284 | TXA ; Keep the hero number... | ||||||
| 7285 | PHA ; ...across the plot | ||||||
| 7286 | JSR plot_sprite ; Plot the health's units digit | ||||||
| 7289 | PLA ; Recover the hero number... | ||||||
| 728A | TAX ; ...into X, as the caller had it | ||||||
| 728B | RTS ; Return with the health drawn and X the hero | ||||||
Add one point to a hero's scoreAdd one to hero X's score and redraw it in the status panel. Points come one at a time from here: a monster killed by a missile or by magic, a hit on an energy drainer, food (five calls) and a door opened (seven); draw_status_panel calls it at each level just to draw the score, which adds a point. Bigger rewards go through add_ten_points. The score is kept as digit sprites, one table per digit (hero_score_thousands, _hundreds, _tens, _units; &1E-&27 for 0-9), so it can be plotted as it stands. A units digit past 9 is set back to 0 and the carry made by falling into add_ten_points, which goes on into the hundreds and, through add_thousand_points, the thousands and the small ten-thousands digit. draw_score then plots all four main digits.
|
|||||||
| 728C | .add_point←5← 0F02 JSR← 1D05 JSR← 73A9 JSR← 76A2 JSR← 76D4 JSR | ||||||
| INC hero_score_units,x ; Score up one: the units digit sprite | |||||||
| 728F | LDA hero_score_units,x ; ...and look at the new units digit | ||||||
| 7292 | CMP #spr_digit_9 + 1 ; Past the 9 sprite? | ||||||
| 7294 | BNE draw_score ; No: nothing to carry, redraw the score | ||||||
| 7296 | LDA #spr_digit_0 ; Yes: units back to 0... | ||||||
| 7298 | STA hero_score_units,x ; ...and carry by falling into add_ten_points | ||||||
| fall through ↓ | |||||||
Add ten points to a hero's scoreAdd ten to hero X's score, carrying into the hundreds and through add_thousand_points, and redraw the score. collect_objects calls it for treasure (twice: 20 points), the Cross of Resurrection and every magic item; add_point falls into it to carry from the units. The units digit is not touched, which the potion relies on: it reads the units digit before calling this.
|
|||||||
| 729B | .add_ten_points←4← 737F JSR← 7382 JSR← 7419 JSR← 74D5 JSR | ||||||
| INC hero_score_tens,x ; Score up ten: the tens digit sprite | |||||||
| 729E | LDA hero_score_tens,x ; ...and look at the new tens digit | ||||||
| 72A1 | CMP #spr_digit_9 + 1 ; Past the 9 sprite? | ||||||
| 72A3 | BNE draw_score ; No: nothing to carry, redraw the score | ||||||
| 72A5 | LDA #spr_digit_0 ; Yes: tens back to 0... | ||||||
| 72A7 | STA hero_score_tens,x ; ...stored for this hero | ||||||
| 72AA | INC hero_score_hundreds,x ; ...and carry into the hundreds | ||||||
| 72AD | LDA hero_score_hundreds,x ; ...and look at the new hundreds digit | ||||||
| 72B0 | CMP #spr_digit_9 + 1 ; Past the 9 sprite? | ||||||
| 72B2 | BNE draw_score ; No: redraw the score | ||||||
| 72B4 | LDA #spr_digit_0 ; Yes: hundreds back to 0... | ||||||
| 72B6 | STA hero_score_hundreds,x ; ...stored for this hero | ||||||
| 72B9 | JSR add_thousand_points ; ...and carry into the thousands and beyond | ||||||
| ; Draw hero X's score, four digit sprites (thousands, hundreds, ; tens, units, three byte columns apart from panel_left) twelve ; rows below the health. The ten-thousands digit is drawn by ; add_thousand_points when it changes. | |||||||
| 72BC | .draw_score←3← 7294 BNE← 72A3 BNE← 72B2 BNE | ||||||
| CLC ; Score: all four digits, twelve rows below the health | |||||||
| 72BD | LDA hero_panel_y,x ; Row: the hero's panel section... | ||||||
| 72C0 | ADC #&0c ; ...twelve rows down, below the health | ||||||
| 72C2 | STA plot_y ; ...as the plotting row | ||||||
| 72C4 | LDA #panel_left ; Thousands digit in the panel's left column | ||||||
| 72C6 | STA plot_x ; ...as the plotting column | ||||||
| 72C8 | LDA hero_score_thousands,x ; The thousands digit sprite... | ||||||
| 72CB | STA sprite_number ; ...as the sprite to plot | ||||||
| 72CD | TXA ; Keep the hero number... | ||||||
| 72CE | PHA ; ...across the plot | ||||||
| 72CF | JSR plot_sprite ; Plot the thousands digit | ||||||
| 72D2 | PLA ; Recover the hero number... | ||||||
| 72D3 | TAX ; ...into X, for the hundreds digit | ||||||
| 72D4 | LDA hero_score_hundreds,x ; The hundreds digit sprite... | ||||||
| 72D7 | STA sprite_number ; ...as the sprite to plot | ||||||
| 72D9 | LDA #panel_left + 3 ; ...three byte columns right (&48)... | ||||||
| 72DB | STA plot_x ; ...as the plotting column | ||||||
| 72DD | TXA ; Keep the hero number... | ||||||
| 72DE | PHA ; ...across the plot | ||||||
| 72DF | JSR plot_sprite ; Plot the hundreds digit | ||||||
| 72E2 | PLA ; Recover the hero number... | ||||||
| 72E3 | TAX ; ...into X, for the tens digit | ||||||
| 72E4 | LDA hero_score_tens,x ; The tens digit sprite... | ||||||
| 72E7 | STA sprite_number ; ...as the sprite to plot | ||||||
| 72E9 | LDA #panel_left + 6 ; ...six byte columns right (&4B)... | ||||||
| 72EB | STA plot_x ; ...as the plotting column | ||||||
| 72ED | TXA ; Keep the hero number... | ||||||
| 72EE | PHA ; ...across the plot | ||||||
| 72EF | JSR plot_sprite ; Plot the tens digit | ||||||
| 72F2 | PLA ; Recover the hero number... | ||||||
| 72F3 | TAX ; ...into X, for the units digit | ||||||
| 72F4 | LDA hero_score_units,x ; The units digit sprite... | ||||||
| 72F7 | STA sprite_number ; ...as the sprite to plot | ||||||
| 72F9 | LDA #panel_left + 9 ; ...nine byte columns right (&4E)... | ||||||
| 72FB | STA plot_x ; ...as the plotting column | ||||||
| 72FD | TXA ; Keep the hero number... | ||||||
| 72FE | PHA ; ...across the plot | ||||||
| 72FF | JSR plot_sprite ; Plot the units digit | ||||||
| 7302 | PLA ; Recover the hero number... | ||||||
| 7303 | TAX ; ...into X, as the caller had it | ||||||
| 7304 | RTS ; Return with the score drawn and X the hero | ||||||
Draw the level's objectsDraw every object still on the level (treasure, food, teleporters, drainers, magic items, the exit) in whichever views show it. update_game calls this every frame, after move_heroes and the door and key checks and before move_missiles and update_monsters, so an object that a hero has just walked off or a monster has crossed is put back before the next sprites are drawn over it. Objects 30 (the exit) down to 1 are plotted with plot_at_cell, their type being their sprite, squarely in their cells (no pixel offset). Object 0 is not drawn. A collected or worn-away object has map x and y &FF (off_map), which plot_at_cell works out to a room offset (&DB) that no view shows, so it is not drawn.
|
||||||||
| 7305 | .draw_objects←1← 1ECE JSR | |||||||
| LDA #0 ; No pixel offsets | ||||||||
| 7307 | STA plot_offset_x ; ...across the cell horizontally... | |||||||
| 7309 | STA plot_offset_y ; ...and vertically: objects sit squarely in their cells | |||||||
| 730B | LDX #max_object ; Objects 30 to 1: plot each at its cell | |||||||
| 730D | .draw_each_object←1← 7326 BNE | |||||||
| LDA object_x,x ; This object's map x... | ||||||||
| 7310 | STA cell_x ; ...is the cell to plot at... | |||||||
| 7313 | LDA object_y,x ; ...and its map y... | |||||||
| 7316 | STA cell_y ; ...the cell's row | |||||||
| 7319 | LDA object_type,x ; Its type, which is also its sprite... | |||||||
| 731C | STA sprite_number ; ...as the sprite to plot | |||||||
| 731E | TXA ; Keep the object number... | |||||||
| 731F | PHA ; ...across the plot | |||||||
| 7320 | JSR plot_at_cell ; Plot it in every view showing its cell | |||||||
| 7323 | PLA ; Recover the object number... | |||||||
| 7324 | TAX ; ...into X, to count down | |||||||
| 7325 | DEX ; Next object down | |||||||
| 7326 | BNE draw_each_object ; Until object 1 is drawn (object 0 is not drawn) | |||||||
| 7328 | RTS ; Return to update_game, X = 0 | |||||||
Pick up the object in a hero's cellGive hero X whatever lies in the cell they have just stepped into: pick up treasure, food, the Cross or a magic item, ride a teleporter, or suffer an energy drainer. move_heroes calls this every frame for each hero in play, after drawing them (draw_moved_hero), whether they moved, stood still or fired, and only when object_free_map says the hero's cell can hold an object. A pickup is removed at once, so it acts once; a drainer stays and acts on every frame the hero's cell is its cell: the frame of arrival, each frame standing on it, and the half-step frame of leaving it (the hero's cell changes only on arrival), so walking across one within a room costs at least 20 health. Objects 30 down to 1 are compared with the hero's cell and the first match is acted on. Finding any object at all takes off the hero's Boots of Speed and erases the bolt from the panel, before the type is looked at, so the boots are lost to a teleporter, a drainer or the exit as well as to a pickup. Then, by type (object_type, which is also the sprite): &28 treasure: 20 points and the treasure sound; removed. &29 food: 10 health (to at most 99), 5 points and the food sound; removed. &2B teleporter: the hero is moved to the cell above the previous teleporter in the object list, searching back and wrapping from object 0 to 29, so each leads to the one before it and the first to the last; the cell is not tested for walls or creatures, and a lone teleporter leads to itself. The teleport sound plays and show_hero_room redraws the view. The teleporter stays. &2A Cross of Resurrection: 10 points and the pickup sound; removed, and the first hero in returning_hero_queue starts to materialise where they fell. With nobody waiting it is wasted. &51 the exit: passed over (update_game's check_hero_on_exit deals with it) and the search goes on. &5F and up, magic items: removed, the pickup sound and 10 points, then &5F Boots of Speed (bolt icon, a whole cell per step), &60 helmet (one less health lost per monster blow, to at least 3, and the armour rating redrawn), &61 potion (health set to the score's units digit twice over, e.g. 77), &62 pile of weapons (one more missile in flight, to at most 3, and its icon) and anything else, &63, the magic sword (one more missile damage, to at most 9, redrawn). Anything else (&53-&5E, an energy drainer at one of its stages): hit_sound at pitch &32 and 10 health lost, one point at a time, which can kill. The drainer stays. Treasure, food, the Cross and magic items are removed by setting their map x and y to &FF (off_map), so they are neither drawn nor found again.
|
||||
| 7329 | .collect_objects←1← 70BE JSR | |||
| LDA hero_x,x ; The hero's cell: map x... | ||||
| 732C | STA cell_x ; ...as the cell to search | |||
| 732F | LDA hero_y,x ; ...and map y... | |||
| 7332 | STA cell_y ; ...as cell_y, for the comparisons | |||
| 7335 | LDY #max_object ; Search from object 30, the exit, down to 1 | |||
| 7337 | .check_object←1← 7473 JMP | |||
| LDA object_x,y ; Object Y's map x... | ||||
| 733A | CMP cell_x ; ...the hero's column? | |||
| 733D | BEQ check_object_y ; Yes: compare the row | |||
| 733F | JMP next_object ; No: try the next object | |||
| 7342 | .check_object_y←1← 733D BEQ | |||
| LDA object_y,y ; Object Y's map y... | ||||
| 7345 | CMP cell_y ; ...the hero's row? | |||
| 7348 | BEQ object_found ; Yes: the hero is on object Y | |||
| 734A | JMP next_object ; No: try the next object | |||
| ; Object Y is in the hero's cell. Whatever it is, the hero loses ; the Boots of Speed and their bolt icon first. | ||||
| 734D | .object_found←1← 7348 BEQ | |||
| TYA ; Found: any object at all costs the Boots of Speed | ||||
| 734E | PHA ; Keep the object number... | |||
| 734F | LDA #0 ; ...take the boots off... | |||
| 7351 | STA hero_has_boots,x ; ...this hero: back to normal speed | |||
| 7354 | JSR point_at_boots_icon ; Point at the hero's bolt in the panel... | |||
| 7357 | JSR erase_boots_icon ; ...and erase it | |||
| 735A | PLA ; Recover the object number... | |||
| 735B | TAY ; ...into Y, to read its type | |||
| 735C | LDA object_type,y ; The object's type, which is its sprite | |||
| 735F | CMP #spr_treasure ; Treasure (20 points)? | |||
| 7361 | BNE check_food ; No: try food | |||
| ; Treasure: define envelope 3 and play the treasure sound with ; it, score 20 and remove it. | ||||
| 7363 | TXA ; Treasure: its sound, keeping hero and object | |||
| 7364 | PHA ; Keep the hero... | |||
| 7365 | TYA ; ...and the object... | |||
| 7366 | PHA ; ...across the OSWORD calls | |||
| 7367 | LDX #<(treasure_envelope) ; XY = treasure_envelope, defining envelope 3... | |||
| 7369 | LDY #>(treasure_envelope) ; ...the block in page &19... | |||
| 736B | LDA #osword_envelope ; ...OSWORD 8, ENVELOPE | |||
| 736D | JSR osword ; Define the treasure envelope: ENVELOPE command | |||
| 7370 | LDX #<(treasure_sound) ; ...then XY = treasure_sound, with envelope 3... | |||
| 7372 | LDY #>(treasure_sound) ; ...the next block in page &19... | |||
| 7374 | LDA #osword_sound ; ...OSWORD 7, SOUND | |||
| 7376 | JSR osword ; Play the treasure sound: SOUND command | |||
| 7379 | PLA ; Recover the object... | |||
| 737A | TAY ; ...into Y, to be removed... | |||
| 737B | PLA ; ...and the hero... | |||
| 737C | TAX ; ...into X, to be scored | |||
| 737D | TYA ; Treasure is worth 20 points: | |||
| 737E | PHA ; ...keeping the object number | |||
| 737F | JSR add_ten_points ; Ten points, the score redrawn... | |||
| 7382 | JSR add_ten_points ; ...and ten more | |||
| 7385 | PLA ; Recover the object number... | |||
| 7386 | TAY ; ...into Y, for remove_object | |||
| 7387 | JMP remove_object ; Take the treasure off the level | |||
| 738A | .check_food←1← 7361 BNE | |||
| CMP #spr_food ; Food (10 health, 5 points)? | ||||
| 738C | BNE check_teleporter ; No: try a teleporter | |||
| ; Food: add 10 health (to at most 99), redraw it, score 5, play ; the food sound and remove it. | ||||
| 738E | INC hero_health_tens,x ; Food: +10 health, one on the tens digit... | |||
| 7391 | LDA hero_health_tens,x ; ...and look at the new tens digit | |||
| 7394 | CMP #spr_digit_9 + 1 ; Past the 9 sprite? | |||
| 7396 | BNE redraw_health ; No: health is up by 10 | |||
| 7398 | LDA #spr_digit_9 ; Yes: health is capped at 99... | |||
| 739A | STA hero_health_tens,x ; ...tens digit 9... | |||
| 739D | STA hero_health_units,x ; ...units digit 9, whatever it was | |||
| 73A0 | .redraw_health←1← 7396 BNE | |||
| TYA ; Show the new health and score 5 points: | ||||
| 73A1 | PHA ; Keep the object number | |||
| 73A2 | JSR draw_health ; Redraw the health in the panel | |||
| 73A5 | LDY #5 ; Food is worth 5 points | |||
| 73A7 | .add_food_points←1← 73AF BNE | |||
| TYA ; Keep the count of points to add... | ||||
| 73A8 | PHA ; ...on the stack across add_point and its plots | |||
| 73A9 | JSR add_point ; One point, the score redrawn | |||
| 73AC | PLA ; Recover the count... | |||
| 73AD | TAY ; ...into Y, to count down | |||
| 73AE | DEY ; One fewer to add | |||
| 73AF | BNE add_food_points ; Until all five are added | |||
| 73B1 | TXA ; The food sound, keeping the hero | |||
| 73B2 | PHA ; Keep the hero across the OSWORD call | |||
| 73B3 | LDX #<(food_sound) ; XY = food_sound... | |||
| 73B5 | LDY #>(food_sound) ; ...the block in page &0B... | |||
| 73B7 | LDA #osword_sound ; ...OSWORD 7, SOUND | |||
| 73B9 | JSR osword ; Play the food sound: SOUND command | |||
| 73BC | PLA ; Recover the hero... | |||
| 73BD | TAX ; ...into X, as move_heroes had it | |||
| 73BE | PLA ; Recover the object number... | |||
| 73BF | TAY ; ...into Y, for remove_object | |||
| 73C0 | JMP remove_object ; Take the food off the level | |||
| 73C3 | .check_teleporter←1← 738C BNE | |||
| CMP #spr_teleporter ; Teleporter (moves the hero)? | ||||
| 73C5 | BNE check_cross ; No: try the Cross | |||
| ; Teleporter: find its partner, the nearest teleporter before it ; in the object list, wrapping round to 29 after object 0 (whose ; type, never set by unpack_level, is 0 and never matches). A ; lone teleporter finds itself. | ||||
| 73C7 | .find_previous_teleporter←2← 73D1 BNE← 73D6 JMP | |||
| DEY ; Teleporter: search back from it for the previous... | ||||
| 73C8 | LDA object_type,y ; ...object's type... | |||
| 73CB | CMP #spr_teleporter ; ...a teleporter too? | |||
| 73CD | BEQ teleport ; Yes: it is the destination | |||
| 73CF | CPY #0 ; Searched down to object 0? | |||
| 73D1 | BNE find_previous_teleporter ; No: keep looking backwards | |||
| 73D3 | LDY teleport_last ; Yes: wrap round to 30, so the search goes on at 29 | |||
| 73D6 | JMP find_previous_teleporter ; ...(the one found may be this teleporter itself) | |||
| ; Y is the destination teleporter. The hero arrives standing on ; the cell above it, whatever is there, and their view is moved ; to that cell's room. | ||||
| 73D9 | .teleport←1← 73CD BEQ | |||
| TXA ; The teleport sound, keeping hero and destination | ||||
| 73DA | PHA ; Keep the hero... | |||
| 73DB | TYA ; ...and the destination teleporter... | |||
| 73DC | PHA ; ...across the OSWORD call | |||
| 73DD | LDX #<(teleport_sound) ; XY = teleport_sound... | |||
| 73DF | LDY #>(teleport_sound) ; ...the block in page &0B... | |||
| 73E1 | LDA #osword_sound ; ...OSWORD 7, SOUND | |||
| 73E3 | JSR osword ; Play the teleport sound: SOUND command | |||
| 73E6 | PLA ; Recover the destination... | |||
| 73E7 | TAY ; ...into Y, to read its cell... | |||
| 73E8 | PLA ; ...and the hero... | |||
| 73E9 | TAX ; ...into X, the hero to move | |||
| 73EA | LDA object_x,y ; Move the hero to the cell above the destination... | |||
| 73ED | STA hero_x,x ; ...the destination's column... | |||
| 73F0 | STA cell_x ; ...and cell_x (show_hero_room sets it again) | |||
| 73F3 | LDA object_y,y ; ...and its row... | |||
| 73F6 | SEC ; ...less one: the row above it... | |||
| 73F7 | SBC #1 ; ...so the hero does not stand on it and teleport back | |||
| 73F9 | STA hero_y,x ; ...as the hero's row (wall or not: it is not tested) | |||
| 73FC | STA cell_y ; ...and cell_y, likewise | |||
| 73FF | LDA #0 ; Arrive standing still: | |||
| 7401 | STA hero_step,x ; ...not part way through a step | |||
| 7404 | STA hero_offset_x,x ; ...and no pixel offsets... | |||
| 7407 | STA hero_offset_y,x ; ...in either direction | |||
| 740A | JMP show_hero_room ; Point the hero's view at the room arrived in | |||
| 740D | .check_cross←1← 73C5 BNE | |||
| CMP #spr_cross ; Cross of Resurrection? | ||||
| 740F | BNE check_magic_item ; No: try the exit, drainers and magic items | |||
| ; Cross of Resurrection: remove it and score 10 whether or not ; anyone is waiting to return, play the pickup sound, then look ; at the front of returning_hero_queue. | ||||
| 7411 | LDA #off_map ; Cross: take it off the level... | |||
| 7413 | STA object_x,y ; ...off the map in x... | |||
| 7416 | STA object_y,y ; ...and y, even if nobody comes back | |||
| 7419 | JSR add_ten_points ; The Cross is worth 10 points | |||
| 741C | TXA ; Keep the hero... | |||
| 741D | PHA ; ...across the sound and the queue | |||
| 741E | JSR play_pickup_sound ; Play the pickup sound | |||
| 7421 | LDA returning_hero_queue ; First queue entry used (a hero or a &64 marker)? | |||
| 7424 | BNE take_returning_hero ; Yes: bring back the first hero waiting | |||
| 7426 | PLA ; No: wasted. Recover the hero... | |||
| 7427 | TAX ; ...into X... | |||
| 7428 | RTS ; ...and return, the Cross spent on nobody | |||
| ; Bring back the first hero waiting in returning_hero_queue. ; Each pass takes the front entry and shifts the four entries up ; one; &64 markers, which stand for heroes left out on the menu, ; are put back at the end and the next entry taken. A hero found ; is started materialising (the death animation run backwards, ; by animate_absent_hero) in the cell where they fell. | ||||
| 7429 | .take_returning_hero←1← 7424 BNE | |||
| LDY #0 ; Take the first entry off the queue, appending 0... | ||||
| 742B | .shift_returning_queue←1← 744A BNE | |||
| LDX returning_hero_queue ; First entry: a hero number + 1, the &64 marker or 0... | ||||
| 742E | DEX ; ...minus 1: the hero, &63 for the marker, &FF for none | |||
| 742F | LDA returning_hero_queue + 1 ; Shift the queue up one: the second entry... | |||
| 7432 | STA returning_hero_queue ; ...becomes the first... | |||
| 7435 | LDA returning_hero_queue + 2 ; ...the third entry... | |||
| 7438 | STA returning_hero_queue + 1 ; ...becomes the second... | |||
| 743B | LDA returning_hero_queue + 3 ; ...the fourth entry... | |||
| 743E | STA returning_hero_queue + 2 ; ...becomes the third... | |||
| 7441 | STY returning_hero_queue + 3 ; ...and Y fills the last (0, or the marker sent back) | |||
| 7444 | CPX #nobody_returns - 1 ; A &64 marker (a hero absent from the menu)? | |||
| 7446 | BNE check_queue_empty ; No: a hero, or nobody | |||
| 7448 | LDY #nobody_returns ; Yes: send it to the back and take the next entry | |||
| 744A | BNE shift_returning_queue ; ...(always taken: Y is &64) | |||
| 744C | .check_queue_empty←1← 7446 BNE | |||
| CPX #&ff ; &FF: the front entry was 0, nobody left waiting? | ||||
| 744E | BEQ cross_done ; Yes: nobody returns | |||
| 7450 | LDA #0 ; Start hero X materialising: out of play... | |||
| 7452 | STA hero_direction,x ; ...direction 0: not in play while the sprites run | |||
| 7455 | LDA #8 ; ...from the skull back... | |||
| 7457 | STA hero_frame,x ; ...frame 8, the last of hero_appearance_sprites | |||
| 745A | LDA #&ff ; ...stepping backwards through the sprites... | |||
| 745C | STA hero_offset_x,x ; ...frame step -1 | |||
| 745F | LDA #1 ; ...the first step next frame | |||
| 7461 | STA hero_offset_y,x ; ...the frame counter | |||
| 7464 | .cross_done←1← 744E BEQ | |||
| PLA ; Recover the hero who picked up the Cross... | ||||
| 7465 | TAX ; ...into X, for move_heroes | |||
| 7466 | RTS ; Return to move_heroes | |||
| ; Shared tail for treasure and food: take object Y off the map. | ||||
| 7467 | .remove_object←2← 7387 JMP← 73C0 JMP | |||
| LDA #off_map ; Take object Y off the level: | ||||
| 7469 | STA object_x,y ; ...off the map in x... | |||
| 746C | STA object_y,y ; ...and y, so it is neither drawn nor found again | |||
| 746F | RTS ; Return to move_heroes: the object is gone | |||
| ; The object is not in the hero's cell, or is the exit: try the ; next one down. | ||||
| 7470 | .next_object←3← 733F JMP← 734A JMP← 747D BEQ | |||
| DEY ; Next object down | ||||
| 7471 | BEQ collect_objects_done ; Past object 1: nothing in the cell | |||
| 7473 | JMP check_object ; Check this object | |||
| 7476 | .collect_objects_done←1← 7471 BEQ | |||
| RTS ; Return: nothing to act on in the hero's cell | ||||
| ; Not treasure, food, a teleporter or the Cross: the exit, an ; energy drainer or a magic item, told apart by type ranges ; alone. | ||||
| 7477 | .check_magic_item←1← 740F BNE | |||
| CMP #spr_boots ; Type &5F or above: a magic item? | ||||
| 7479 | BCS magic_item ; Yes: collect the magic item | |||
| 747B | CMP #spr_exit ; The exit? The main loop deals with it... | |||
| 747D | BEQ next_object ; ...so search on for another object in the cell | |||
| ; An energy drainer (&53-&5E): sound it by playing hit_sound ; with its pitch changed to &32 for the call, then take 10 ; health one point at a time. The drainer stays, and acts again ; on every frame the hero's cell is its cell. | ||||
| 747F | LDA #&32 ; Any other type is an energy drainer: pitch &32... | |||
| 7481 | STA hit_sound + 4 ; ...instead of 6 in hit_sound, the drainer's noise | |||
| 7484 | TXA ; Keep the hero... | |||
| 7485 | PHA ; ...across the OSWORD call | |||
| 7486 | LDX #<(hit_sound) ; XY = hit_sound, now at the drainer's pitch... | |||
| 7488 | LDY #>(hit_sound) ; ...the block in page &0C... | |||
| 748A | LDA #osword_sound ; ...OSWORD 7, SOUND | |||
| 748C | JSR osword ; The drainer's noise: SOUND command | |||
| 748F | LDA #6 ; ...then pitch 6 again... | |||
| 7491 | STA hit_sound + 4 ; ...for monster_hit's blow | |||
| 7494 | PLA ; Recover the hero... | |||
| 7495 | TAX ; ...into X, for lose_health_point | |||
| 7496 | LDY #&0a ; The drainer takes 10 health and stays | |||
| 7498 | .take_ten_health←1← 74A0 BNE | |||
| TYA ; Keep the count... | ||||
| 7499 | PHA ; ...on the stack: lose_health_point corrupts Y | |||
| 749A | JSR lose_health_point ; One point of the hero's health | |||
| 749D | PLA ; Recover the count... | |||
| 749E | TAY ; ...into Y, to count down | |||
| 749F | DEY ; One fewer to take | |||
| 74A0 | BNE take_ten_health ; Until all ten are taken | |||
| 74A2 | RTS ; Return: the drainer stays, to act again next frame | |||
Play the pickup soundPlay the sound of a Cross or magic item being picked up. collect_objects calls it for both. Envelope 3 is defined as the pickup envelope and the pickup sound played with it on the noise channel, from the OSWORD parameter blocks pickup_envelope and pickup_sound. Envelope 3 is shared with the treasure, key and exit sounds, which define their own, so it is defined again each time.
|
||||||||
| 74A3 | .play_pickup_sound←2← 741E JSR← 74CA JSR | |||||||
| LDX #<(pickup_envelope) ; XY = pickup_envelope, defining envelope 3... | ||||||||
| 74A5 | LDY #>(pickup_envelope) ; ...the block in page &19... | |||||||
| 74A7 | LDA #osword_envelope ; ...OSWORD 8, ENVELOPE | |||||||
| 74A9 | JSR osword ; Define it: ENVELOPE command | |||||||
| 74AC | LDX #<(pickup_sound) ; ...then XY = pickup_sound, with envelope 3... | |||||||
| 74AE | LDY #>(pickup_sound) ; ...the next block in page &19... | |||||||
| 74B0 | LDA #osword_sound ; ...OSWORD 7, SOUND | |||||||
| 74B2 | JSR osword ; Play it: SOUND command | |||||||
| 74B5 | RTS ; Return, A, X and Y corrupted by the OSWORDs | |||||||
| ; A magic item, type &5F or above: removed, the pickup sound, ; and 10 points for every kind. The type then picks boots, ; helmet, potion or weapons, and any other type counts as a ; magic sword. | ||||||||
| 74B6 | .magic_item←1← 7479 BCS | |||||||
| STA scratch ; A magic item: keep its type for the tests below | ||||||||
| 74B9 | LDA #off_map ; Take it off the level... | |||||||
| 74BB | STA object_x,y ; ...off the map in x... | |||||||
| 74BE | STA object_y,y ; ...and y, so it is neither drawn nor found again | |||||||
| 74C1 | TXA ; The pickup sound, keeping the hero | |||||||
| 74C2 | PHA ; Keep the hero across the sound | |||||||
| 74C3 | LDA scratch ; A = (type AND 7) x 4: unused, as play_pickup_sound... | |||||||
| 74C6 | AND #7 ; ...sets its own registers... | |||||||
| 74C8 | ASL ; ...x 2... | |||||||
| 74C9 | ASL ; ...x 4, then lost to the OSWORD calls | |||||||
| 74CA | JSR play_pickup_sound ; Play the pickup sound | |||||||
| 74CD | PLA ; Recover the hero... | |||||||
| 74CE | TAX ; ...into X, to be scored | |||||||
| 74CF | LDA hero_score_units,x ; The score's units digit sprite... | |||||||
| 74D2 | STA scratch2 ; ...kept for a potion (add_ten_points leaves it) | |||||||
| 74D5 | JSR add_ten_points ; Every magic item is worth 10 points | |||||||
| 74D8 | LDA scratch ; The item's type... | |||||||
| 74DB | CMP #spr_boots ; ...Boots of Speed? | |||||||
| 74DD | BNE check_helmet ; No: try the helmet | |||||||
| ; Boots of Speed: show the bolt and let the hero step a whole ; cell a frame, until they next find an object. | ||||||||
| 74DF | JSR point_at_boots_icon ; Boots: point at the hero's bolt in the panel... | |||||||
| 74E2 | JSR plot_boots_icon ; ...and show it | |||||||
| 74E5 | LDA #1 ; ...and wear them... | |||||||
| 74E7 | STA hero_has_boots,x ; ...so the hero moves a whole cell per step | |||||||
| 74EA | RTS ; Return to move_heroes, the boots on | |||||||
| 74EB | .check_helmet←1← 74DD BNE | |||||||
| CMP #spr_helmet ; Magic helmet (better armour)? | ||||||||
| 74ED | BNE check_potion ; No: try the potion | |||||||
| ; Magic helmet: lower hero_damage_taken, the health a monster's ; blow takes, by one to at least 3, and redraw the armour rating ; (10 - hero_damage_taken, so at most 7). | ||||||||
| 74EF | DEC hero_damage_taken,x ; Helmet: one less health lost per hit... | |||||||
| 74F2 | LDA hero_damage_taken,x ; ...and look at it | |||||||
| 74F5 | CMP #3 ; ...below 3 (armour 7, the best)? | |||||||
| 74F7 | BCS redraw_armour ; No: keep it | |||||||
| 74F9 | INC hero_damage_taken,x ; Yes: back to 3 | |||||||
| 74FC | .redraw_armour←1← 74F7 BCS | |||||||
| JMP draw_armour_rating ; Redraw the armour rating on the shield | ||||||||
| 74FF | .check_potion←1← 74ED BNE | |||||||
| CMP #spr_potion ; Potion of healing? | ||||||||
| 7501 | BNE check_weapons ; No: try the weapons | |||||||
| ; Potion of healing: health is set from the score's units digit ; d, read before the 10 points were added, as tens d and units d ; + 1, then lose_health_point takes a point and draws it: health ; dd, from 00 to 99. | ||||||||
| 7503 | LDA scratch2 ; Potion: health = the score's last digit twice... | |||||||
| 7506 | STA hero_health_tens,x ; ...as the tens (so a score ending in 0 gives 00) | |||||||
| 7509 | INC scratch2 ; ...and the units one higher... | |||||||
| 750C | LDA scratch2 ; ...the sprite after it... | |||||||
| 750F | STA hero_health_units,x ; ...as the health's units | |||||||
| 7512 | JSR lose_health_point ; ...less a point, which also draws the health | |||||||
| 7515 | RTS ; Return to move_heroes with the new health drawn | |||||||
| 7516 | .check_weapons←1← 7501 BNE | |||||||
| CMP #spr_weapons ; Pile of weapons? | ||||||||
| 7518 | BNE magic_sword ; No: anything else is taken as a magic sword | |||||||
| ; Pile of weapons: one more missile allowed in flight, to at ; most 3 (the hero's three missile slots), and its icon added. | ||||||||
| 751A | INC hero_max_missiles,x ; Weapons: one more missile in flight at once... | |||||||
| 751D | LDA hero_max_missiles,x ; ...and look at it | |||||||
| 7520 | CMP #4 ; ...past 3, the hero's missile slots? | |||||||
| 7522 | BNE draw_missile_icon ; No: add its icon to the panel | |||||||
| 7524 | LDA #3 ; Yes: back to 3... | |||||||
| 7526 | STA hero_max_missiles,x ; ...as the missiles allowed | |||||||
| 7529 | .draw_missile_icon←1← 7522 BNE | |||||||
| JMP draw_new_missile_icon ; Draw the newest missile icon | ||||||||
Show the room a hero has moved intoMake hero X's view show the room they are now in, and redraw that view's walls and doors. move_heroes calls this when a hero steps into another room, and a teleporter jumps here after moving the hero. Each hero has a fixed view (0 top left to 3 bottom right). test_wall is called on the hero's cell only for the room offset it leaves in map_ptr; that becomes the low byte of the view's view_room entry (view_room + 2 x hero), the pointer into room_walls that draw_view_0 to draw_view_3 and plot_at_cell read; the high byte never changes. The matching draw_view_n then draws the room's walls and doors. Creatures and objects appear in the new view as they are next plotted.
|
|||||||
| 752C | .show_hero_room←2← 704D JSR← 740A JMP | ||||||
| LDA hero_x,x ; The hero's cell, for test_wall to find its room | |||||||
| 752F | STA cell_x ; ...as cell_x for test_wall... | ||||||
| 7532 | LDA hero_y,x ; ...and its map y... | ||||||
| 7535 | STA cell_y ; ...as cell_y for test_wall | ||||||
| 7538 | TXA ; Keep the hero... | ||||||
| 7539 | PHA ; ...on the stack: test_wall corrupts X | ||||||
| 753A | JSR test_wall ; Only for map_ptr: the offset of the cell's room | ||||||
| 753D | PLA ; Recover the hero... | ||||||
| 753E | TAX ; ...into X, to pick their view | ||||||
| 753F | PHA ; Keep the hero number across the view draw | ||||||
| 7540 | ASL ; Hero x 2: their view's entry in view_room... | ||||||
| 7541 | TAY ; ...two bytes, a pointer into room_walls | ||||||
| 7542 | LDA map_ptr ; The room's offset that test_wall left... | ||||||
| 7544 | STA view_room,y ; ...becomes the view's room | ||||||
| ; Redraw the hero's own view, which is fixed by hero number. | |||||||
| 7547 | CPX #0 ; Redraw this hero's own view: hero 0's? | ||||||
| 7549 | BNE check_view_1 ; No: try hero 1 | ||||||
| 754B | JSR draw_view_0 ; Hero 0: redraw the top-left view | ||||||
| 754E | PLA ; Recover the hero... | ||||||
| 754F | TAX ; ...into X, as the caller had it | ||||||
| 7550 | RTS ; Return with the Ranger's view redrawn | ||||||
| 7551 | .check_view_1←1← 7549 BNE | ||||||
| CPX #1 ; Hero 1, the top-right view? | |||||||
| 7553 | BNE check_view_2 ; No: try hero 2 | ||||||
| 7555 | JSR draw_view_1 ; Yes: redraw it | ||||||
| 7558 | PLA ; Recover the hero... | ||||||
| 7559 | TAX ; ...into X, as the caller had it | ||||||
| 755A | RTS ; Return with the Magic-User's view redrawn | ||||||
| 755B | .check_view_2←1← 7553 BNE | ||||||
| CPX #2 ; Hero 2, the bottom-left view? | |||||||
| 755D | BNE show_view_3 ; No: hero 3 | ||||||
| 755F | JSR draw_view_2 ; Yes: redraw it | ||||||
| 7562 | PLA ; Recover the hero... | ||||||
| 7563 | TAX ; ...into X, as the caller had it | ||||||
| 7564 | RTS ; Return with the Barbarian's view redrawn | ||||||
| 7565 | .show_view_3←1← 755D BNE | ||||||
| JSR draw_view_3 ; Hero 3: redraw the bottom-right view | |||||||
| 7568 | PLA ; Recover the hero... | ||||||
| 7569 | TAX ; ...into X, as the caller had it | ||||||
| 756A | RTS ; Return with the Fighter's view redrawn | ||||||
| ; Magic sword: one more damage for each missile the hero fires ; from now on, to at most 9, and the panel's damage digit ; redrawn. Missiles already in flight keep their damage. | |||||||
| 756B | .magic_sword←1← 7518 BNE | ||||||
| INC hero_missile_damage,x ; Magic sword: one more damage per missile... | |||||||
| 756E | LDA hero_missile_damage,x ; ...and look at it | ||||||
| 7571 | CMP #&0a ; ...past 9, the most? | ||||||
| 7573 | BNE draw_missile_damage ; No: draw the new damage in the panel | ||||||
| 7575 | LDA #9 ; Yes: back to 9... | ||||||
| 7577 | STA hero_missile_damage,x ; ...as the missile damage | ||||||
| 757A | BNE draw_missile_damage ; ...and draw it (always taken) | ||||||
| ; A missile has hit a live monster: X is the monster, Y the ; missile slot. Reached by JMP from move_missiles, and leaves by ; jumping back into it. Every hit makes the hit sound. The ; missile's damage is taken from the monster's hit points; below ; 0 kills it (0 survives), and the kill is scored by ; monster_killed. Either way the missile is spent. | |||||||
| 757C | .monster_hit←1← 714D JMP | ||||||
| TXA ; Hit: sound the blow | |||||||
| 757D | PHA ; Keep the monster... | ||||||
| 757E | TYA ; ...and the missile slot... | ||||||
| 757F | PHA ; ...across the OSWORD call | ||||||
| 7580 | LDX #<(hit_sound) ; XY = hit_sound, at pitch 6... | ||||||
| 7582 | LDY #>(hit_sound) ; ...the block in page &0C... | ||||||
| 7584 | LDA #osword_sound ; ...OSWORD 7, SOUND | ||||||
| 7586 | JSR osword ; Sound the blow: SOUND command | ||||||
| 7589 | PLA ; Recover the missile slot... | ||||||
| 758A | TAY ; ...into Y, for its damage... | ||||||
| 758B | PLA ; ...and the monster... | ||||||
| 758C | TAX ; ...into X, for its hit points | ||||||
| 758D | LDA monster_hit_points,x ; The monster's hit points... | ||||||
| 7590 | SEC ; ...set the carry for the subtraction... | ||||||
| 7591 | SBC missile_damage,y ; ...less this missile's damage | ||||||
| 7594 | BPL store_monster_health ; 0 or more: alive (0 hit points survives a hit) | ||||||
| ; Killed: the monster's sprite becomes the blank, from which ; update_monsters runs the sparkles, and its slot is given this ; level's starting hit points for when it comes back at a ; trapdoor. | |||||||
| 7596 | LDA #spr_blank ; Below 0: killed. Start it dying... | ||||||
| 7598 | STA monster_sprite,x ; ...from the blank sprite through the sparkles | ||||||
| 759B | LDA monster_start_hit_points ; ...and give the slot this level's hit points... | ||||||
| 759E | STA monster_hit_points,x ; ...ready for when it comes back at a trapdoor | ||||||
| 75A1 | TYA ; Missile slot back in X... | ||||||
| 75A2 | TAX ; ...as monster_killed expects | ||||||
| 75A3 | JMP monster_killed ; ...a point to its hero, and the missile is spent | ||||||
| 75A6 | .store_monster_health←1← 7594 BPL | ||||||
| STA monster_hit_points,x ; Alive: store the hit points left | |||||||
| 75A9 | TYA ; Push the missile slot, as missile_spent_pop... | ||||||
| 75AA | PHA ; ...expects to find it on the stack | ||||||
| 75AB | JMP missile_spent_pop ; The missile is spent: one hit per missile | ||||||
| ; Redraw hero X's armour rating after a magic helmet: the small ; digit 10 - hero_damage_taken (at most 7) on the shield in ; their panel section, twelve rows above the health. Jumped to ; from collect_objects; returns to its caller with X kept. | |||||||
| 75AE | .draw_armour_rating←1← 74FC JMP | ||||||
| SEC ; Armour rating = 10 - health lost per hit, drawn... | |||||||
| 75AF | LDA hero_panel_y,x ; ...on the shield: the hero's panel row... | ||||||
| 75B2 | SBC #&0c ; ...less twelve pixel rows... | ||||||
| 75B4 | STA plot_y ; ...as the plotting row | ||||||
| 75B6 | LDA #panel_left + 9 ; ...byte column &4E, nine right of the panel's left... | ||||||
| 75B8 | STA plot_x ; ...as the plotting column | ||||||
| 75BA | LDA #spr_small_digit_1 + 9 ; Small digit 10... | ||||||
| 75BC | SEC ; ...set the carry for the subtraction... | ||||||
| 75BD | SBC hero_damage_taken,x ; ...less the health lost per hit: 1 to 7 | ||||||
| 75C0 | STA sprite_number ; ...as the sprite to plot | ||||||
| 75C2 | JMP plot_keeping_x ; Plot it, keeping X, and return | ||||||
| ; Add the icon for hero X's newest missile after a pile of ; weapons, at the row draw_status_panel would give it (icon n at ; its row &0D + 3n, which plot_panel_sprite offsets by the panel ; row - &0E). Icons are only added: with 3 already allowed the ; third is drawn again. Jumped to from collect_objects; returns ; with X kept. | |||||||
| 75C5 | .draw_new_missile_icon←1← 7529 JMP | ||||||
| LDA hero_max_missiles,x ; Icon for the newest missile allowed: missiles x 2... | |||||||
| 75C8 | ASL ; ...(x 2)... | ||||||
| 75C9 | CLC ; ...clear the carry for the addition... | ||||||
| 75CA | ADC hero_max_missiles,x ; ...+ missiles again: 3 rows per icon... | ||||||
| 75CD | ADC #&0d ; ...+ &0D, as in draw_status_panel's icon rows... | ||||||
| 75CF | ADC hero_panel_y,x ; ...+ the hero's panel row... | ||||||
| 75D2 | SEC ; ...set the carry for the subtraction... | ||||||
| 75D3 | SBC #&0e ; ...- &0E, plot_panel_sprite's bias: the same row | ||||||
| 75D5 | STA plot_y ; ...as the plotting row | ||||||
| 75D7 | LDA #panel_left + 6 ; ...byte column &4B, the icons' column... | ||||||
| 75D9 | STA plot_x ; ...as the plotting column | ||||||
| 75DB | LDA #spr_missile_icon ; The missile icon... | ||||||
| 75DD | STA sprite_number ; ...as the sprite to plot | ||||||
| 75DF | JMP plot_keeping_x ; Plot it, keeping X, and return | ||||||
| ; Redraw hero X's missile damage after a magic sword, as a small ; digit (1-9) four rows above their panel row. Jumped to from ; collect_objects; returns with X kept. | |||||||
| 75E2 | .draw_missile_damage←2← 7573 BNE← 757A BNE | ||||||
| LDA #panel_left + 7 ; Missile damage: byte column &4C... | |||||||
| 75E4 | STA plot_x ; ...as the plotting column | ||||||
| 75E6 | SEC ; ...set the carry for the subtraction... | ||||||
| 75E7 | LDA hero_panel_y,x ; ...the hero's panel row... | ||||||
| 75EA | SBC #4 ; ...less four pixel rows... | ||||||
| 75EC | STA plot_y ; ...as the plotting row | ||||||
| 75EE | LDA hero_missile_damage,x ; The damage, 1-9... | ||||||
| 75F1 | CLC ; ...clear the carry for the addition... | ||||||
| 75F2 | ADC #spr_small_digit_1 - 1 ; ...+ one before small digit 1: its small digit | ||||||
| 75F4 | STA sprite_number ; ...as the sprite to plot | ||||||
| 75F6 | JMP plot_keeping_x ; Plot it, keeping X, and return | ||||||
Set the position of a hero's boots iconSet plot_x to the panel's column &4A and plot_y to eight pixel rows above hero X's panel row (hero_panel_y), where the lightning bolt shows that the hero wears Boots of Speed. collect_objects calls it before plot_boots_icon, when boots are picked up, and before erase_boots_icon, when any object is found under the hero.
|
|||||||||||
| 75F9 | .point_at_boots_icon←2← 7354 JSR← 74DF JSR | ||||||||||
| LDA #panel_left + 5 ; The bolt's byte column, &4A... | |||||||||||
| 75FB | STA plot_x ; ...as the plotting column | ||||||||||
| 75FD | SEC ; ...set the carry for the subtraction... | ||||||||||
| 75FE | LDA hero_panel_y,x ; ...the hero's panel row... | ||||||||||
| 7601 | SBC #8 ; ...8 rows above the hero's panel section | ||||||||||
| 7603 | STA plot_y ; ...as the icon's pixel row | ||||||||||
| 7605 | RTS ; Return with plot_x, plot_y at the hero's boots icon | ||||||||||
Show a hero's boots iconPlot the lightning bolt at plot_x, plot_y, where point_at_boots_icon has just pointed, to show that hero X now wears Boots of Speed. Called when the boots are picked up. The plot goes through plot_keeping_x, which keeps the hero number across plot_sprite (which leaves X = 0).
|
|||||||||||
| 7606 | .plot_boots_icon←1← 74E2 JSR | ||||||||||
| LDA #spr_boots_icon ; The lightning bolt: the hero has Boots of Speed... | |||||||||||
| 7608 | STA sprite_number ; ...as the sprite to plot | ||||||||||
| 760A | JMP plot_keeping_x ; ...plotted where point_at_boots_icon pointed | ||||||||||
Remove a hero's boots iconPlot the blank boots sprite over the lightning bolt at plot_x, plot_y, where point_at_boots_icon has just pointed. collect_objects calls this whenever a hero finds any object, since every find takes the boots off. Falls into plot_keeping_x.
|
|||||||||||
| 760D | .erase_boots_icon←1← 7357 JSR | ||||||||||
| LDA #spr_blank_boots_icon ; The blank: the boots are lost... | |||||||||||
| 760F | STA sprite_number ; ...as the sprite to plot | ||||||||||
| 7611 | .plot_keeping_x←4← 75C2 JMP← 75DF JMP← 75F6 JMP← 760A JMP | ||||||||||
| TXA ; Keep the hero number... | |||||||||||
| 7612 | PHA ; ...on the stack: plot_sprite leaves X = 0 | ||||||||||
| 7613 | JSR plot_sprite ; Plot the icon in the hero's panel section | ||||||||||
| 7616 | PLA ; Recover the hero number... | ||||||||||
| 7617 | TAX ; ...in X again for the caller | ||||||||||
| 7618 | RTS ; Return with X = the hero again | ||||||||||
Cast a hero's magic if their key is heldLet the Ranger or the Magic-User cast magic, which kills every live monster in the room they are in. move_heroes jumps here (JMP, not JSR) for heroes 0 and 1 when they stand in a cell, before reading their other keys. hero_magic_delay is counted down first. It normally stands at 1, so the magic key (hero_magic_key) is scanned every frame; while it is not yet zero the RTS here returns from move_heroes itself, so neither this hero nor those after it move that frame. Without the key held, play goes on to read_hero_keys. With it held, the magic sound plays, the delay is set to 4 (three frozen frames follow) and the cost is taken one health point at a time: 6 for the Ranger, 3 for the Magic-User, which can kill the caster. Then every monster whose cell lies in the room the caster's view shows, and whose sprite is below the blank (alive), is given the blank sprite, the first frame of a death that update_monsters plays out, and the caster scores a point for each, through add_point, even if the cost has just killed them. Unlike a missile's kill, the magic does not reset the monster's hit points, so a monster wounded before comes back from its trapdoor still wounded. The caster does not move that frame: play goes on at draw_moved_hero, which draws them if still in play.
|
||||
| 7619 | .check_magic←1← 6EBE JMP | |||
| DEC hero_magic_delay,x ; Count down this hero's magic key delay | ||||
| 761C | BEQ read_magic_key ; Zero: time to look at the magic key | |||
| 761E | RTS ; Not yet: RTS ends move_heroes; later heroes wait too | |||
| 761F | .read_magic_key←1← 761C BEQ | |||
| LDA #1 ; Delay 1: the key is read every frame from now on | ||||
| 7621 | STA hero_magic_delay,x ; ...so the next press is seen at once | |||
| 7624 | LDA hero_magic_key,x ; This hero's magic key, an INKEY number... | |||
| 7627 | JSR test_key ; ...scanned: Z set if held | |||
| 762A | BNE no_magic ; Not held: read the movement and fire keys | |||
| ; Cast the magic: play its sound, take the caster's health, then ; kill every live monster in the room the caster's view shows, a ; point each. | ||||
| 762C | TXA ; Held: cast. Keep the hero number... | |||
| 762D | PHA ; ...on the stack: X carries the OSWORD blocks | |||
| 762E | LDX #<(magic_envelope) ; XY = magic_envelope, an OSWORD 8 block... | |||
| 7630 | LDY #>(magic_envelope) ; ...and its page | |||
| 7632 | LDA #osword_envelope ; OSWORD 8: define the magic envelope | |||
| 7634 | JSR osword ; ENVELOPE command | |||
| 7637 | LDX #<(magic_sound) ; XY = magic_sound, an OSWORD 7 block... | |||
| 7639 | LDY #>(magic_sound) ; ...and its page | |||
| 763B | LDA #osword_sound ; OSWORD 7: make the magic sound | |||
| 763D | JSR osword ; SOUND command | |||
| 7640 | PLA ; Recover the hero number... | |||
| 7641 | TAX ; ...the caster, in X again | |||
| ; Hold off the key for three frames, then take the cost, 6 ; health for the Ranger and 3 for the Magic-User, a point at a ; time through lose_health_point. The caster may die of it; the ; spell still goes on. | ||||
| 7642 | LDA #4 ; Ignore the key for the next three frames | |||
| 7644 | STA hero_magic_delay,x ; ...so one press casts only once | |||
| 7647 | CPX #1 ; Health cost: 3 for the Magic-User... | |||
| 7649 | BEQ magic_user_cost ; Magic-User (hero 1): the cheaper rate | |||
| 764B | LDY #6 ; ...6 for the Ranger | |||
| 764D | JMP take_magic_cost ; Ranger: go and take 6 points | |||
| 7650 | .magic_user_cost←1← 7649 BEQ | |||
| LDY #3 ; Magic-User: 3 points | ||||
| 7652 | .take_magic_cost←2← 764D JMP← 765A BNE | |||
| TYA ; Pay the cost one health point at a time | ||||
| 7653 | PHA ; ...the points left on the stack | |||
| 7654 | JSR lose_health_point ; One point off the caster, redrawn (it can kill them) | |||
| 7657 | PLA ; Recover the points left... | |||
| 7658 | TAY ; ...back in Y | |||
| 7659 | DEY ; One point fewer to take | |||
| 765A | BNE take_magic_cost ; Until the whole cost is paid | |||
| 765C | LDA #0 ; No monsters killed yet: | |||
| 765E | STA magic_kill_count ; ...magic_kill_count counts this cast's kills | |||
| 7661 | TXA ; The caster's view_room index, 2 x hero... | |||
| 7662 | ASL ; ...x 2: view_room holds two bytes per hero | |||
| 7663 | STA sprite_number ; ...kept in sprite_number, free as scratch here | |||
| ; Kill every live monster in the caster's room. A monster parked ; off the map (&FF) is in no room and survives. The kill only ; sets the first death frame; hit points are left as they are. | ||||
| 7665 | LDX #max_monster ; For each monster, 30 to 1... | |||
| 7667 | .check_magic_monster←1← 7693 BNE | |||
| LDA monster_x,x ; ...find its room from its cell: map x... | ||||
| 766A | STA cell_x ; ...as cell_x for test_wall... | |||
| 766D | LDA monster_y,x ; ...and map y... | |||
| 7670 | STA cell_y ; ...as cell_y; the wall bit is not wanted | |||
| 7673 | TXA ; Keep the monster number... | |||
| 7674 | PHA ; ...on the stack across test_wall | |||
| 7675 | JSR test_wall ; test_wall leaves the monster's room in map_ptr | |||
| 7678 | PLA ; Recover the monster number... | |||
| 7679 | TAX ; ...back in X | |||
| 767A | LDY sprite_number ; Y = the caster's view_room index | |||
| 767C | LDA view_room,y ; The room the caster's view shows... | |||
| 767F | CMP map_ptr ; ...is it the monster's room? | |||
| 7681 | BNE next_monster_magic ; Another room: the monster is spared | |||
| 7683 | LDA monster_sprite,x ; Alive? (dying ones are sprite &15 up) | |||
| 7686 | CMP #spr_blank ; Below the first death frame: alive | |||
| 7688 | BCS next_monster_magic ; Already dying: not counted again | |||
| 768A | LDA #spr_blank ; Alive: the first death frame, &15... | |||
| 768C | STA monster_sprite,x ; ...and update_monsters plays out its death | |||
| 768F | INC magic_kill_count ; ...a kill to score | |||
| 7692 | .next_monster_magic←2← 7681 BNE← 7688 BCS | |||
| DEX ; Next monster down | ||||
| 7693 | BNE check_magic_monster ; Until monster 1 is done | |||
| ; Score a point for each kill, to the caster, through add_point. | ||||
| 7695 | LDA sprite_number ; One point for each monster killed | |||
| 7697 | LSR ; ...halve the view_room index back to the hero | |||
| 7698 | TAX ; ...X = the caster, who scores the points | |||
| 7699 | LDY magic_kill_count ; ...Y = the monsters killed | |||
| 769C | .score_magic_kills←1← 76A8 JMP | |||
| CPY #0 ; Any kills left to score? | ||||
| 769E | BEQ magic_cast ; None left: redraw the caster | |||
| 76A0 | TYA ; Keep the kills left... | |||
| 76A1 | PHA ; ...on the stack across add_point | |||
| 76A2 | JSR add_point ; One point to the caster | |||
| 76A5 | PLA ; Recover the kills left... | |||
| 76A6 | TAY ; ...back in Y | |||
| 76A7 | DEY ; One kill fewer to score | |||
| 76A8 | JMP score_magic_kills ; Score the next | |||
| 76AB | .no_magic←1← 762A BNE | |||
| JMP read_hero_keys ; No cast: read the movement and fire keys | ||||
| 76AE | .magic_cast←1← 769E BEQ | |||
| JMP draw_moved_hero ; Cast: no move this frame; redraw the caster | ||||
Give a point to the hero who fired a missileScore one point for the hero whose missile is in slot X. move_missiles calls this when a missile kills a monster (through monster_killed) and when it wears down an energy drainer. The firer is told by the missile's sprite base, as in flip_firer_frame: arrows the Ranger, fireballs the Magic-User, axes the Barbarian, and anything else the Fighter. add_point adds the point and redraws the score, whether or not the firer is still in play.
|
|||||||||||
| 76B1 | .credit_missile_owner←2← 7150 JSR← 71A2 JSR | ||||||||||
| LDY missile_sprite_base,x ; Which hero fired it? Its sprite base says | |||||||||||
| 76B4 | TXA ; Keep the missile slot... | ||||||||||
| 76B5 | PHA ; ...on the stack: X becomes the hero | ||||||||||
| 76B6 | TYA ; The sprite base, to compare | ||||||||||
| 76B7 | CMP #spr_arrow_up - 1 ; ...the arrows' base, one below the up arrow? | ||||||||||
| 76B9 | BNE owner_fireball ; Not arrows: try fireballs | ||||||||||
| 76BB | LDX #0 ; Arrows: the Ranger, hero 0 | ||||||||||
| 76BD | JMP credit_owner ; Credit the Ranger | ||||||||||
| 76C0 | .owner_fireball←1← 76B9 BNE | ||||||||||
| CMP #spr_fireball_up - 1 ; ...the fireballs' base? | |||||||||||
| 76C2 | BNE owner_axe ; Not fireballs: try axes | ||||||||||
| 76C4 | LDX #1 ; Fireballs: the Magic-User, hero 1 | ||||||||||
| 76C6 | JMP credit_owner ; Credit the Magic-User | ||||||||||
| 76C9 | .owner_axe←1← 76C2 BNE | ||||||||||
| CMP #spr_axe_up - 1 ; ...the axes' base? | |||||||||||
| 76CB | BNE owner_sword ; Not axes: so it must be swords | ||||||||||
| 76CD | LDX #2 ; Axes: the Barbarian, hero 2 | ||||||||||
| 76CF | JMP credit_owner ; Credit the Barbarian | ||||||||||
| 76D2 | .owner_sword←1← 76CB BNE | ||||||||||
| LDX #3 ; Otherwise swords: the Fighter, hero 3 | |||||||||||
| 76D4 | .credit_owner←3← 76BD JMP← 76C6 JMP← 76CF JMP | ||||||||||
| JSR add_point ; One point to the firer's score | |||||||||||
| 76D7 | PLA ; Recover the missile slot... | ||||||||||
| 76D8 | TAX ; ...in X again for move_missiles | ||||||||||
| 76D9 | RTS ; Return with X = the missile slot again | ||||||||||
Animate a hero who is out of playPlay a dying hero's sparkles and skull, or a returning hero's skull and sparkles in reverse, at the cell where they fell. move_heroes calls this each frame, in the hero's turn, for a hero out of play (direction 0) unless nobody plays them (step &63). While out of play the hero's offset bytes are reused: hero_offset_y is a two-frame timer and hero_offset_x the step through the sequence (+1 or -1), both set by lose_health_point for a death and by collect_objects for a Cross of Resurrection. Every other frame, plot hero_appearance_sprites entry hero_frame at the hero's cell, with no pixel offset, then step hero_frame by hero_offset_x: forwards (+1) for a hero dying, stopping at the skull (entry 8), which is then redrawn every other frame until a Cross brings the hero back; backwards (-1) for a hero returning through a Cross of Resurrection, from entry 8. A dying hero starts from their walking frame (0 or 1), which lose_health_point does not reset, so the first sparkle may be skipped. A returning hero is put back in play as hero_frame reaches 0, so entry 0 is never shown on the way back: they come back in the cell where they fell, facing down, standing squarely in it, with health 32 (set to 33 and drawn by taking a point). move_heroes draws them on their next turn.
|
|||||||||||
| 76DA | .animate_absent_hero←1← 6E91 JSR | ||||||||||
| DEC hero_offset_y,x ; Every other frame: count down the timer... | |||||||||||
| 76DD | BEQ absent_frame_due ; Timer run out: show the next sprite | ||||||||||
| 76DF | RTS ; Not yet: nothing to draw this frame | ||||||||||
| ; Due: plot the sprite for the hero's place in the sequence at ; their cell. | |||||||||||
| 76E0 | .absent_frame_due←1← 76DD BEQ | ||||||||||
| LDA #2 ; Restart the two-frame timer... | |||||||||||
| 76E2 | STA hero_offset_y,x ; ...which an absent hero keeps in hero_offset_y | ||||||||||
| 76E5 | JSR get_hero_cell ; Plot the current appearance sprite at the hero's cell | ||||||||||
| 76E8 | LDA #0 ; No pixel offsets (those bytes hold timer and step)... | ||||||||||
| 76EA | STA plot_offset_x ; ...none across... | ||||||||||
| 76EC | STA plot_offset_y ; ...and none down | ||||||||||
| 76EE | LDA hero_frame,x ; The hero's place in the appearance sequence... | ||||||||||
| 76F1 | TAY ; ...as an index... | ||||||||||
| 76F2 | LDA hero_appearance_sprites,y ; ...picks the sparkle or skull to show | ||||||||||
| 76F5 | STA sprite_number ; ...as the sprite to plot | ||||||||||
| 76F7 | TXA ; Keep the hero number... | ||||||||||
| 76F8 | PHA ; ...on the stack: plot_at_cell changes X | ||||||||||
| 76F9 | JSR plot_at_cell ; Plot it in every view that shows the hero | ||||||||||
| 76FC | PLA ; Recover the hero number... | ||||||||||
| 76FD | TAX ; ...back in X | ||||||||||
| ; Step to the next place, holding a dying hero at the skull ; (place 8). | |||||||||||
| 76FE | CLC ; Step to the next (+1 dying, -1 returning), stopping at 8 | ||||||||||
| 76FF | LDA hero_frame,x ; Current place in the sequence... | ||||||||||
| 7702 | ADC hero_offset_x,x ; ...plus the step kept in hero_offset_x | ||||||||||
| 7705 | CMP #9 ; Past the skull (place 8)? | ||||||||||
| 7707 | BCC check_hero_returned ; No: keep the new place | ||||||||||
| 7709 | LDA #8 ; Yes: a dead hero stays on the skull | ||||||||||
| 770B | .check_hero_returned←1← 7707 BCC | ||||||||||
| CMP #0 ; Place 0? Only a returning hero gets there | |||||||||||
| 770D | BNE store_hero_frame ; No: store the new place for the next plot | ||||||||||
| ; A returning hero has reached place 0: put them back in play, ; facing down, squarely in their cell, with 32 health. | |||||||||||
| 770F | LDA #5 ; Yes: back in play before place 0 is shown... | ||||||||||
| 7711 | STA hero_direction,x ; ...facing down (direction 5) | ||||||||||
| 7714 | LDA #0 ; ...with no step or offsets... | ||||||||||
| 7716 | STA hero_step,x ; ...not mid-step... | ||||||||||
| 7719 | STA hero_offset_x,x ; ...no horizontal offset... | ||||||||||
| 771C | STA hero_offset_y,x ; ...no vertical offset... | ||||||||||
| 771F | STA hero_frame,x ; ...and animation frame 0 | ||||||||||
| 7722 | LDA #spr_digit_3 ; ...and health 33, drawn by taking a point | ||||||||||
| 7724 | STA hero_health_tens,x ; ...tens digit 3... | ||||||||||
| 7727 | STA hero_health_units,x ; ...units digit 3... | ||||||||||
| 772A | JSR lose_health_point ; ...less a point, which also draws it: 32 | ||||||||||
| 772D | RTS ; Return with the hero back in play | ||||||||||
| 772E | .store_hero_frame←1← 770D BNE | ||||||||||
| STA hero_frame,x ; Store the new place, to show in two frames | |||||||||||
| 7731 | RTS ; Return; the hero stays out of play | ||||||||||
Draw a heroPlot sprite_number at hero X's cell, shifted by their pixel offsets (half a cell along while a step is under way), in every view that shows it. move_heroes calls it each frame for every hero in play, at draw_moved_hero, with the hero's sprite for their direction and frame; lose_health_point calls it with the blank to erase a hero who has just died. cell_x and cell_y are left as plot_at_cell leaves them, as positions within the view, so callers needing the map cell load it again.
|
|||||||||||||
| 7732 | .draw_hero←2← 70A4 JSR← 7244 JSR | ||||||||||||
| JSR get_hero_cell ; The hero's map cell... | |||||||||||||
| 7735 | LDA hero_offset_x,x ; ...and the pixel offsets of a step in progress | ||||||||||||
| 7738 | STA plot_offset_x ; ...the column offset (0 or +-2) as plot_offset_x... | ||||||||||||
| 773A | LDA hero_offset_y,x ; ...and the row offset (0 or +-6)... | ||||||||||||
| 773D | STA plot_offset_y ; ...as plot_offset_y | ||||||||||||
| 773F | TXA ; Keep the hero number... | ||||||||||||
| 7740 | PHA ; ...on the stack: each plot leaves X = 0 | ||||||||||||
| 7741 | JSR plot_at_cell ; Plot the hero in every view showing it | ||||||||||||
| 7744 | PLA ; Recover the hero number... | ||||||||||||
| 7745 | TAX ; ...in X again for the caller | ||||||||||||
| 7746 | RTS ; Return with X = the hero again | ||||||||||||
Animate the hero who fired a missileToggle the animation frame (0 or 1) of the hero whose missile is in slot X, so the hero's sprite changes as they throw. move_missiles calls this on a missile's first move, while bit 7 of its direction still marks it as just fired; move_heroes flipped the frame when it fired, so this flips it back, and the throw shows for one frame. The firer is told by the missile's sprite base (one less than its up sprite): arrows the Ranger, fireballs the Magic-User, axes the Barbarian, and anything else the Fighter. The hero is not redrawn here; the new frame shows when move_heroes next draws them.
|
|||||||||
| 7747 | .flip_firer_frame←1← 70E1 JSR | ||||||||
| LDA missile_sprite_base,x ; Which hero fired it? Its sprite base says | |||||||||
| 774A | CMP #spr_arrow_up - 1 ; ...the arrows' base, one below the up arrow? | ||||||||
| 774C | BNE firer_fireball ; Not arrows: try fireballs | ||||||||
| 774E | LDA hero_frame ; The Ranger's animation frame... | ||||||||
| 7751 | EOR #1 ; ...flipped between 0 and 1... | ||||||||
| 7753 | STA hero_frame ; ...so the Ranger's sprite changes as they fire | ||||||||
| 7756 | RTS ; Return; X is still the missile slot | ||||||||
| 7757 | .firer_fireball←1← 774C BNE | ||||||||
| CMP #spr_fireball_up - 1 ; ...the fireballs' base? | |||||||||
| 7759 | BNE firer_axe ; Not fireballs: try axes | ||||||||
| 775B | LDA hero_frame + 1 ; The Magic-User's animation frame... | ||||||||
| 775E | EOR #1 ; ...flipped between 0 and 1... | ||||||||
| 7760 | STA hero_frame + 1 ; ...so the Magic-User's sprite changes as they cast | ||||||||
| 7763 | RTS ; Return; X is still the missile slot | ||||||||
| 7764 | .firer_axe←1← 7759 BNE | ||||||||
| CMP #spr_axe_up - 1 ; ...the axes' base? | |||||||||
| 7766 | BNE firer_sword ; Not axes: so it must be swords | ||||||||
| 7768 | LDA hero_frame + 2 ; The Barbarian's animation frame... | ||||||||
| 776B | EOR #1 ; ...flipped between 0 and 1... | ||||||||
| 776D | STA hero_frame + 2 ; ...so the Barbarian's sprite changes as they throw | ||||||||
| 7770 | RTS ; Return; X is still the missile slot | ||||||||
| 7771 | .firer_sword←1← 7766 BNE | ||||||||
| LDA load_core_store_filev ; Otherwise swords: the Fighter's frame... | |||||||||
| 7774 | EOR #1 ; ...flipped between 0 and 1... | ||||||||
| 7776 | STA load_core_store_filev ; ...so the Fighter's sprite changes as they throw | ||||||||
| 7779 | RTS ; Return; X is still the missile slot | ||||||||
Copy a hero's position to cell_x, cell_yLoad hero X's map cell into cell_x and cell_y, ready for plot_at_cell. Used by draw_hero and animate_absent_hero.
|
|||||||||||||
| 777A | .get_hero_cell←2← 76E5 JSR← 7732 JSR | ||||||||||||
| LDA hero_x,x ; The hero's map x... | |||||||||||||
| 777D | STA cell_x ; ...as cell_x, for plot_at_cell | ||||||||||||
| 7780 | LDA hero_y,x ; ...and map y... | ||||||||||||
| 7783 | STA cell_y ; ...as cell_y | ||||||||||||
| 7786 | RTS ; Return with the hero's cell in cell_x, cell_y | ||||||||||||
| 7787 | EQUB &73 ; Not referenced | ||||||||||||
Draw all four viewsDraw the walls and doors of the room in each hero's view: the Ranger's top left, the Magic-User's top right, the Barbarian's bottom left and the Fighter's bottom right. draw_view_frames calls it once as each level starts, after drawing the frames round the views, when every view_room entry holds the heroes' starting room. A view is drawn even for a hero nobody plays. Since each draw_room plots every door in every view showing its room, the doors of a room shared by several views are drawn several times over. Heroes, monsters and objects appear as the first frame of play plots them.
|
||||||||
| 7788 | .draw_all_views←1← 1502 JSR | |||||||
| JSR draw_view_0 ; The Ranger's view, top left | ||||||||
| 778B | JSR draw_view_1 ; The Magic-User's view, top right | |||||||
| 778E | JSR draw_view_2 ; The Barbarian's view, bottom left | |||||||
| 7791 | JSR draw_view_3 ; The Fighter's view, bottom right | |||||||
| 7794 | RTS ; Return with all four rooms drawn | |||||||
Draw the top-left viewDraw the walls and doors of the room in hero 0's view, the Ranger's, whose top-left cell starts at byte column 1, pixel row 1 (see plot_at_cell for the view coordinates). draw_all_views calls this as a level starts, and show_hero_room when hero 0 enters another room. The view's corner is passed to draw_room in plot_y and, for want of a spare variable, in cell_x; only the low byte of view_room is passed, in map_ptr, as draw_room supplies page &0C.
|
|||||||||||
| 7795 | .draw_view_0←2← 754B JSR← 7788 JSR | ||||||||||
| LDA #1 ; Top-left view: pixel row 1... | |||||||||||
| 7797 | STA plot_y ; ...as the view's top pixel row | ||||||||||
| 7799 | LDA #1 ; ...byte column 1... | ||||||||||
| 779B | STA cell_x ; ...in cell_x, as draw_room expects | ||||||||||
| 779E | LDA view_room ; ...the room the Ranger's view shows | ||||||||||
| 77A1 | STA map_ptr ; ...whose walls draw_room reads | ||||||||||
| 77A3 | JSR draw_room ; Draw its walls and doors | ||||||||||
| 77A6 | RTS ; Return with the top-left view redrawn | ||||||||||
Draw the top-right viewDraw the room in hero 1's view, the Magic-User's, whose top-left is byte column &23, pixel row 1. Called as draw_view_0 is.
|
|||||||||||
| 77A7 | .draw_view_1←2← 7555 JSR← 778B JSR | ||||||||||
| LDA #1 ; Top-right view: pixel row 1... | |||||||||||
| 77A9 | STA plot_y ; ...as the view's top pixel row | ||||||||||
| 77AB | LDA #view_right_column ; ...byte column &23... | ||||||||||
| 77AD | STA cell_x ; ...as the view's left screen column | ||||||||||
| 77B0 | LDA view_room + 2 ; ...the room the Magic-User's view shows | ||||||||||
| 77B3 | STA map_ptr ; ...whose walls draw_room reads | ||||||||||
| 77B5 | JSR draw_room ; Draw its walls and doors | ||||||||||
| 77B8 | RTS ; Return with the top-right view redrawn | ||||||||||
Draw the bottom-left viewDraw the room in hero 2's view, the Barbarian's, whose top-left is byte column 1, pixel row &67. Called as draw_view_0 is.
|
|||||||||||
| 77B9 | .draw_view_2←2← 755F JSR← 778E JSR | ||||||||||
| LDA #view_bottom_row ; Bottom-left view: pixel row &67... | |||||||||||
| 77BB | STA plot_y ; ...as the view's top pixel row | ||||||||||
| 77BD | LDA #1 ; ...byte column 1... | ||||||||||
| 77BF | STA cell_x ; ...as the view's left screen column | ||||||||||
| 77C2 | LDA view_room + 4 ; ...the room the Barbarian's view shows | ||||||||||
| 77C5 | STA map_ptr ; ...whose walls draw_room reads | ||||||||||
| 77C7 | JSR draw_room ; Draw its walls and doors | ||||||||||
| 77CA | RTS ; Return with the bottom-left view redrawn | ||||||||||
Draw the bottom-right viewDraw the room in hero 3's view, the Fighter's, whose top-left is byte column &23, pixel row &67. Called as draw_view_0 is.
|
|||||||||||
| 77CB | .draw_view_3←2← 7565 JSR← 7791 JSR | ||||||||||
| LDA #view_bottom_row ; Bottom-right view: pixel row &67... | |||||||||||
| 77CD | STA plot_y ; ...as the view's top pixel row | ||||||||||
| 77CF | LDA #view_right_column ; ...byte column &23... | ||||||||||
| 77D1 | STA cell_x ; ...as the view's left screen column | ||||||||||
| 77D4 | LDA view_room + 6 ; ...the room the Fighter's view shows | ||||||||||
| 77D7 | STA map_ptr ; ...whose walls draw_room reads | ||||||||||
| 77D9 | JSR draw_room ; Draw its walls and doors | ||||||||||
| 77DC | RTS ; Return with the bottom-right view redrawn | ||||||||||
| 77DD | EQUB &60 ; Not referenced | ||||||||||
Draw a roomRepaint one view with the walls of its room and the level's doors, wiping whatever the view showed before. Called by draw_view_0 to draw_view_3, so as a level starts and whenever a hero changes room. The room's eight wall bytes (see test_wall for the map layout) are read through map_ptr, whose high byte is set here to page &0C (room_walls). Each byte is one row of cells: draw_room_row plots a wall block or a blank in each of its eight cells, and plot_y moves down twelve pixel rows for the next. Every cell is painted, so this also wipes the previous room's creatures and objects; they reappear as they are next plotted. Then each of doors 20 to 1 is plotted at its map cell through plot_at_cell, which draws it only in views whose room holds it, and in every such view, not just this one. A closed door's cell is also a wall in room_walls, so it is first drawn as a wall block and then covered by the door; an opened door has its wall bit cleared and its position set to off_map, so it is drawn nowhere.
|
|||||||||||||||||||
| 77DE | .draw_room←4← 77A3 JSR← 77B5 JSR← 77C7 JSR← 77D9 JSR | ||||||||||||||||||
| LDA #>(room_walls) ; The room's walls are in page &0C | |||||||||||||||||||
| 77E0 | STA map_ptr_hi ; ...so map_ptr points at the room's wall bytes | ||||||||||||||||||
| ; Walls: paint each of the room's eight rows of cells, wall or ; blank, from its wall byte, twelve pixel rows apart. | |||||||||||||||||||
| 77E2 | LDY #0 ; For each of the room's eight rows of cells... | ||||||||||||||||||
| 77E4 | .draw_room_walls←1← 77FA BNE | ||||||||||||||||||
| LDA (map_ptr),y ; ...take its eight wall bits... | |||||||||||||||||||
| 77E6 | STA scratch ; ...in scratch for draw_room_row | ||||||||||||||||||
| 77E9 | TYA ; Keep the row number... | ||||||||||||||||||
| 77EA | PHA ; ...on the stack across the row | ||||||||||||||||||
| 77EB | JSR draw_room_row ; ...and draw the row's walls and blanks | ||||||||||||||||||
| 77EE | CLC ; Twelve pixel rows down | ||||||||||||||||||
| 77EF | LDA plot_y ; Down to the next row of cells... | ||||||||||||||||||
| 77F1 | ADC #&0c ; ...each 12 pixel rows tall | ||||||||||||||||||
| 77F3 | STA plot_y ; ...ready for the next row | ||||||||||||||||||
| 77F5 | PLA ; Recover the row number... | ||||||||||||||||||
| 77F6 | TAY ; ...back in Y | ||||||||||||||||||
| 77F7 | INY ; Next row of the room down | ||||||||||||||||||
| 77F8 | CPY #8 ; All eight rows done? | ||||||||||||||||||
| 77FA | BNE draw_room_walls ; No: draw the next row | ||||||||||||||||||
| ; Doors: plot every door on the level through plot_at_cell, ; which shows only those in rooms on view, in every such view. | |||||||||||||||||||
| 77FC | LDX #max_door ; Then doors 20 to 1, wherever they are on the map | ||||||||||||||||||
| 77FE | .draw_room_doors←1← 781D BNE | ||||||||||||||||||
| LDA door_x,x ; This door's map x... | |||||||||||||||||||
| 7801 | STA cell_x ; ...as the cell to plot | ||||||||||||||||||
| 7804 | LDA door_y,x ; ...and its map y (off_map once opened)... | ||||||||||||||||||
| 7807 | STA cell_y ; ...as cell_y | ||||||||||||||||||
| 780A | LDA #0 ; Doors sit squarely in their cells: | ||||||||||||||||||
| 780C | STA plot_offset_x ; ...no horizontal offset... | ||||||||||||||||||
| 780E | STA plot_offset_y ; ...and no vertical offset | ||||||||||||||||||
| 7810 | LDA door_sprite,x ; Its sprite, vertical or horizontal... | ||||||||||||||||||
| 7813 | STA sprite_number ; ...as the sprite to plot | ||||||||||||||||||
| 7815 | TXA ; Keep the door number... | ||||||||||||||||||
| 7816 | PHA ; ...on the stack: plot_at_cell changes X | ||||||||||||||||||
| 7817 | JSR plot_at_cell ; Plot it in every view showing its cell | ||||||||||||||||||
| 781A | PLA ; Recover the door number... | ||||||||||||||||||
| 781B | TAX ; ...in X for the count | ||||||||||||||||||
| 781C | DEX ; Next door down | ||||||||||||||||||
| 781D | BNE draw_room_doors ; Until door 1 is drawn | ||||||||||||||||||
| 781F | RTS ; Return with the room and its doors drawn | ||||||||||||||||||
Draw one row of a roomPlot a wall block or a blank in each of the eight cells of one row of a view, from bit 7 of scratch (the leftmost cell) to bit 0, four byte columns apart, starting at byte column cell_x. Called by draw_room for each row. The cells are plotted with plot_sprite directly, in this view only.
|
|||||||||||||||||
| 7820 | .draw_room_row←1← 77EB JSR | ||||||||||||||||
| LDA cell_x ; Start at the view's left edge | |||||||||||||||||
| 7823 | STA plot_x ; ...as the first cell's screen column | ||||||||||||||||
| 7825 | LDX #&80 ; Bit mask, starting with the leftmost cell | ||||||||||||||||
| 7827 | .draw_room_cell←1← 784F BNE | ||||||||||||||||
| TXA ; Keep this cell's bit mask... | |||||||||||||||||
| 7828 | PHA ; ...on the stack: plot_sprite leaves X = 0... | ||||||||||||||||
| 7829 | STA scratch2 ; ...and in scratch2 for the test | ||||||||||||||||
| 782C | LDA scratch ; Wall in this cell? | ||||||||||||||||
| 782F | AND scratch2 ; ...against the row's wall bits | ||||||||||||||||
| 7832 | BEQ plot_blank ; No: an open cell, blanked | ||||||||||||||||
| 7834 | LDA #spr_wall ; Yes: plot the wall block (sprite 0) | ||||||||||||||||
| 7836 | STA sprite_number ; ...as the sprite to plot | ||||||||||||||||
| 7838 | JSR plot_sprite ; Draw the wall block in this cell | ||||||||||||||||
| 783B | JMP next_room_cell ; On to the next cell | ||||||||||||||||
| 783E | .plot_blank←1← 7832 BEQ | ||||||||||||||||
| LDA #spr_blank ; Plot the blank (sprite &15) | |||||||||||||||||
| 7840 | STA sprite_number ; ...as the sprite to plot | ||||||||||||||||
| 7842 | JSR plot_sprite ; Clear whatever the view showed there | ||||||||||||||||
| 7845 | .next_room_cell←1← 783B JMP | ||||||||||||||||
| CLC ; Four byte columns right | |||||||||||||||||
| 7846 | LDA plot_x ; Next cell's screen column... | ||||||||||||||||
| 7848 | ADC #4 ; ...four bytes, one cell's width, along | ||||||||||||||||
| 784A | STA plot_x ; ...stored for the next plot | ||||||||||||||||
| 784C | PLA ; This cell's mask back from the stack... | ||||||||||||||||
| 784D | LSR ; ...shifted to the next cell right | ||||||||||||||||
| 784E | TAX ; ...into X; zero once the eighth cell is done | ||||||||||||||||
| 784F | BNE draw_room_cell ; ...until all eight are done | ||||||||||||||||
| 7851 | RTS ; Return with the row drawn, X = 0 | ||||||||||||||||
Plot a sprite at a map cell in every viewDraw (or, with the blank sprite, erase) sprite_number at a map cell, in every view that is showing the cell's room. Heroes, skulls, monsters, sparkles, missiles, objects, keys, doors, trapdoors and the Chalice are all drawn and erased through here; only the walls (draw_room_row) and the status panel are plotted directly. So a cell in a room that two heroes share is drawn in both views, and one in a room that no view shows is not drawn at all. Map coordinates. The dungeon is a grid of cells, x across from 0 at the left, y down from 0 at the top, divided into rooms of 8x8 cells, four rooms across (x 0-31) and six down (y 0-47). A room is named by its offset in room_walls, 32 x its row of rooms + 8 x its column of rooms, which is (y AND &F8) x 4 + (x AND &F8): always a multiple of 8, from 0 to &B8 (test_wall describes the map's bytes). The cell's place within its room is x AND 7, y AND 7. View coordinates. plot_sprite takes a byte column (plot_x, 0-79 across the screen, two MODE 2 pixels each) and a pixel row (plot_y, from 0 at the top). Each view shows one room, 8 cells of 4 byte columns by 8 cells of 12 pixel rows (32 x 96), with its top-left at column 1 or view_right_column (&23) and row 1 or view_bottom_row (&67): hero 0's view top left, 1 top right, 2 bottom left, 3 bottom right. view_room + 2 x hero holds the offset of the room each view shows. A cell's sprite goes at the view's corner + ((x AND 7) x 4 + plot_offset_x, (y AND 7) x 12 + plot_offset_y). The offsets are signed (&FA is 6 rows up) and place a sprite part way between cells while it steps. The room offset is worked out once and compared with the low byte of each view_room entry, views 0 to 3 in turn. A cell at off_map (&FF, &FF), where collected objects, opened doors and parked monsters are put, comes out as &DB, through the carries of the sum: not a multiple of 8, so no view shows it and it is never drawn. There is no clipping, but no hero's or monster's step crosses a room edge, so a stepping sprite stays inside its view. cell_x and cell_y are overwritten with the position within the room, so a caller that needs the map cell again sets them again; code that reads them afterwards without doing so sees these view positions.
|
|||||||||||||||||||
| ; Which room is the cell in? Its offset in room_walls, the same ; number view_room holds for each view. | |||||||||||||||||||
| 7852 | .plot_at_cell←19← 11A8 JSR← 1200 JSR← 1D36 JSR← 1DDC JSR← 1E61 JSR← 1F6D JSR← 1FB7 JSR← 1FEC JSR← 7091 JSR← 70F9 JSR← 7213 JSR← 7320 JSR← 76F9 JSR← 7741 JSR← 7817 JSR← 79DB JSR← 7A07 JSR← 7B25 JSR← 7B5C JSR | ||||||||||||||||||
| LDA cell_y ; Room = (cell_y AND &F8) x 4 + (cell_x AND &F8)... | |||||||||||||||||||
| 7855 | AND #&f8 ; ...y AND &F8 = 8 x the cell's row of rooms... | ||||||||||||||||||
| 7857 | STA scratch ; ...kept in scratch, to add up four times... | ||||||||||||||||||
| 785A | CLC ; ...(y < 64 on the map: no carry, so clear it once) | ||||||||||||||||||
| 785B | ADC scratch ; ...doubled: 16 bytes per row of rooms so far... | ||||||||||||||||||
| 785E | ADC scratch ; ...tripled: 24... | ||||||||||||||||||
| 7861 | ADC scratch ; ...x 4: 32 bytes, four rooms, per row of rooms | ||||||||||||||||||
| 7864 | STA cell_room ; ...the offset of the cell's row of rooms | ||||||||||||||||||
| 7867 | LDA cell_x ; Add the room's column in that row... | ||||||||||||||||||
| 786A | AND #&f8 ; ...x AND &F8 = 8 x the column: 8 bytes per room | ||||||||||||||||||
| 786C | ADC cell_room ; ...giving the room's offset in room_walls (0-&B8) | ||||||||||||||||||
| 786F | STA cell_room ; ...in cell_room, to compare with each view_room | ||||||||||||||||||
| ; Where in a view does the cell go? Its column and row within ; the room, scaled to bytes and pixel rows, plus the sprite's ; offsets. | |||||||||||||||||||
| 7872 | LDA cell_x ; Byte column in a view = (x AND 7) x 4 + offset_x | ||||||||||||||||||
| 7875 | AND #7 ; ...the cell's column within its room, 0-7... | ||||||||||||||||||
| 7877 | ASL ; ...x 2... | ||||||||||||||||||
| 7878 | ASL ; ...x 4: each cell is 4 byte columns wide | ||||||||||||||||||
| 7879 | CLC ; ...clear the carry for the offset | ||||||||||||||||||
| 787A | ADC plot_offset_x ; ...plus the sprite's signed offset in byte columns | ||||||||||||||||||
| 787C | STA cell_x ; ...cell_x is now the column within the view | ||||||||||||||||||
| 787F | LDA cell_y ; Pixel row in a view = (y AND 7) x 12 + offset_y | ||||||||||||||||||
| 7882 | AND #7 ; ...the cell's row within its room, 0-7... | ||||||||||||||||||
| 7884 | ASL ; ...x 2... | ||||||||||||||||||
| 7885 | ASL ; ...x 4... | ||||||||||||||||||
| 7886 | STA scratch ; ...row x 4 kept in scratch, for the sum... | ||||||||||||||||||
| 7889 | ASL ; ...x 8... | ||||||||||||||||||
| 788A | CLC ; ...clear the carry (at most 56 + 28) | ||||||||||||||||||
| 788B | ADC scratch ; ...x 8 + x 4 = x 12: each cell is 12 rows tall | ||||||||||||||||||
| 788E | ADC plot_offset_y ; ...plus the sprite's signed offset in pixel rows | ||||||||||||||||||
| 7890 | STA cell_y ; ...cell_y is now the row within the view | ||||||||||||||||||
| ; Plot it in each view showing that room, at the view's top-left ; corner plus the position within the room. | |||||||||||||||||||
| 7893 | LDA view_room ; The Ranger's view (top left): this room? | ||||||||||||||||||
| 7896 | CMP cell_room ; ...the room the cell is in? | ||||||||||||||||||
| 7899 | BNE check_view_1_room ; Not shown there: try the top-right view | ||||||||||||||||||
| 789B | CLC ; Shown: screen position = view corner (1, 1) + cell's | ||||||||||||||||||
| 789C | LDA #1 ; ...the view's left byte column, 1... | ||||||||||||||||||
| 789E | ADC cell_x ; ...plus the column within the view | ||||||||||||||||||
| 78A1 | STA plot_x ; ...as plot_x | ||||||||||||||||||
| 78A3 | LDA #1 ; ...the view's top pixel row, 1... | ||||||||||||||||||
| 78A5 | ADC cell_y ; ...plus the row within the view | ||||||||||||||||||
| 78A8 | STA plot_y ; ...as plot_y | ||||||||||||||||||
| 78AA | JSR plot_sprite ; Draw it in the top-left view | ||||||||||||||||||
| 78AD | .check_view_1_room←1← 7899 BNE | ||||||||||||||||||
| LDA view_room + 2 ; The Magic-User's view (top right): this room? | |||||||||||||||||||
| 78B0 | CMP cell_room ; ...the room the cell is in? | ||||||||||||||||||
| 78B3 | BNE check_view_2_room ; Not shown there: try the bottom-left view | ||||||||||||||||||
| 78B5 | CLC ; Shown: view corner (&23, 1) + cell's position | ||||||||||||||||||
| 78B6 | LDA #view_right_column ; ...the view's left byte column... | ||||||||||||||||||
| 78B8 | ADC cell_x ; ...plus the column within the view | ||||||||||||||||||
| 78BB | STA plot_x ; ...as plot_x | ||||||||||||||||||
| 78BD | LDA #1 ; ...the view's top pixel row, 1... | ||||||||||||||||||
| 78BF | ADC cell_y ; ...plus the row within the view | ||||||||||||||||||
| 78C2 | STA plot_y ; ...as plot_y | ||||||||||||||||||
| 78C4 | JSR plot_sprite ; Draw it in the top-right view | ||||||||||||||||||
| 78C7 | .check_view_2_room←1← 78B3 BNE | ||||||||||||||||||
| LDA view_room + 4 ; The Barbarian's view (bottom left): this room? | |||||||||||||||||||
| 78CA | CMP cell_room ; ...the room the cell is in? | ||||||||||||||||||
| 78CD | BNE check_view_3_room ; Not shown there: try the bottom-right view | ||||||||||||||||||
| 78CF | CLC ; Shown: view corner (1, &67) + cell's position | ||||||||||||||||||
| 78D0 | LDA #1 ; ...the view's left byte column, 1... | ||||||||||||||||||
| 78D2 | ADC cell_x ; ...plus the column within the view | ||||||||||||||||||
| 78D5 | STA plot_x ; ...as plot_x | ||||||||||||||||||
| 78D7 | LDA #view_bottom_row ; ...the view's top pixel row... | ||||||||||||||||||
| 78D9 | ADC cell_y ; ...plus the row within the view | ||||||||||||||||||
| 78DC | STA plot_y ; ...as plot_y | ||||||||||||||||||
| 78DE | JSR plot_sprite ; Draw it in the bottom-left view | ||||||||||||||||||
| 78E1 | .check_view_3_room←1← 78CD BNE | ||||||||||||||||||
| LDA view_room + 6 ; The Fighter's view (bottom right): this room? | |||||||||||||||||||
| 78E4 | CMP cell_room ; ...the room the cell is in? | ||||||||||||||||||
| 78E7 | BNE plot_at_cell_done ; Not shown there: done | ||||||||||||||||||
| 78E9 | CLC ; Shown: view corner (&23, &67) + cell's position | ||||||||||||||||||
| 78EA | LDA #view_right_column ; ...the view's left byte column... | ||||||||||||||||||
| 78EC | ADC cell_x ; ...plus the column within the view | ||||||||||||||||||
| 78EF | STA plot_x ; ...as plot_x | ||||||||||||||||||
| 78F1 | LDA #view_bottom_row ; ...the view's top pixel row... | ||||||||||||||||||
| 78F3 | ADC cell_y ; ...plus the row within the view | ||||||||||||||||||
| 78F6 | STA plot_y ; ...as plot_y | ||||||||||||||||||
| 78F8 | JSR plot_sprite ; Draw it in the bottom-right view | ||||||||||||||||||
| 78FB | .plot_at_cell_done←1← 78E7 BNE | ||||||||||||||||||
| RTS ; Return; cell_x, cell_y now hold the view position | |||||||||||||||||||
Test for a wall at a map cellSay whether a map cell is solid: a wall, or a door not yet opened. Heroes (move_heroes), missiles (move_missiles) and monsters (update_monsters) test here the cell they are about to enter, and find_open_neighbour the cells next to the exit where drop_key can put a key down. check_magic and show_hero_room call it only for the room pointer it leaves in map_ptr. The wall map. room_walls (&0C00) holds eight bytes per room, one per row of cells from the top, and one bit per cell, bit 7 for the leftmost (x AND 7 = 0) to bit 0 for the rightmost; a set bit is solid. Rooms are stored in rows of four, left to right, so a room's eight bytes start at (y AND &F8) x 4 + (x AND &F8) (see plot_at_cell for the coordinates), and the cell is bit bit_masks[x AND 7] of byte y AND 7 there. object_free_map at &2100 has the same layout (test_object_free). The level file supplies both; opening a door clears its bit. The bit is returned in A and Y, with Z set for an open cell; callers that have pulled X from the stack test Y. map_ptr is left pointing at the room's bytes, its low byte being the room offset that view_room uses. Coordinates off the map are not checked: off_map (&FF, &FF) reads a byte beyond the wall map. The bit is also stored in &8F (victory_pitch), which the victory sequence sets before it reads it, so the copy is never used.
|
|||||||||||||||||
| ; Point map_ptr at the cell's room in room_walls. | |||||||||||||||||
| 78FC | .test_wall←8← 20D3 JSR← 20E1 JSR← 20EF JSR← 6FB2 JSR← 712B JSR← 753A JSR← 7675 JSR← 7A51 JSR | ||||||||||||||||
| LDA cell_y ; Room offset = (cell_y AND &F8) x 4 + (cell_x AND &F8)... | |||||||||||||||||
| 78FF | AND #&f8 ; ...y AND &F8 = 8 x the cell's row of rooms... | ||||||||||||||||
| 7901 | STA scratch ; ...kept in scratch, to add up four times... | ||||||||||||||||
| 7904 | CLC ; ...(y < 64 on the map: no carry, so clear it once) | ||||||||||||||||
| 7905 | ADC scratch ; ...doubled: 16 bytes per row of rooms so far... | ||||||||||||||||
| 7908 | ADC scratch ; ...tripled: 24... | ||||||||||||||||
| 790B | ADC scratch ; ...x 4: 32 bytes, four rooms, per row of rooms | ||||||||||||||||
| 790E | STA map_ptr ; ...the start of its row of rooms, in map_ptr | ||||||||||||||||
| 7910 | LDA cell_x ; Add the room's column in that row... | ||||||||||||||||
| 7913 | AND #&f8 ; ...x AND &F8 = 8 x the column: 8 bytes per room | ||||||||||||||||
| 7915 | ADC map_ptr ; ...to the row's offset... | ||||||||||||||||
| 7917 | STA map_ptr ; ...map_ptr low = the room's offset (0-&B8)... | ||||||||||||||||
| 7919 | LDA #>(room_walls) ; ...in page &0C, room_walls... | ||||||||||||||||
| 791B | STA map_ptr_hi ; ...as map_ptr's high byte: map_ptr = the room's bytes | ||||||||||||||||
| ; Pick out the cell's bit: bit_masks for the column, the room's ; byte for the row. | |||||||||||||||||
| 791D | LDA cell_x ; Mask for the cell's column within the room... | ||||||||||||||||
| 7920 | AND #7 ; ...x AND 7, 0 at the left... | ||||||||||||||||
| 7922 | TAX ; ...in X, to look up its bit... | ||||||||||||||||
| 7923 | LDA bit_masks,x ; ...&80 for column 0 down to &01 for column 7 | ||||||||||||||||
| 7926 | STA scratch ; ...kept in scratch to test the row byte with | ||||||||||||||||
| 7929 | LDA cell_y ; The row byte: y AND 7... | ||||||||||||||||
| 792C | AND #7 ; ...the cell's row within the room, 0-7... | ||||||||||||||||
| 792E | TAY ; ...in Y, indexing the room's eight bytes | ||||||||||||||||
| 792F | LDA (map_ptr),y ; The row's walls, one bit per cell... | ||||||||||||||||
| 7931 | AND scratch ; ...masked to this cell: non-zero if solid | ||||||||||||||||
| 7934 | STA victory_pitch ; ...copied to &8F, which is never read for it... | ||||||||||||||||
| 7936 | TAY ; ...and to Y: callers pull X, then test Y | ||||||||||||||||
| 7937 | RTS ; Return with Z set if the cell is open | ||||||||||||||||
Test whether a map cell can hold an objectSay whether an object might lie in a map cell, so that the object list need be searched only there. move_heroes calls it for a hero who has moved, before collect_objects, and move_missiles for a missile's new cell, before looking for an energy drainer. The same calculation as test_wall, on object_free_map at &2100 instead of room_walls: eight bytes per room, a bit per cell, bit 7 at the left. A clear bit means an object may lie there; the map comes from the level file and is not changed when an object is collected, so a cleared cell goes on costing a search that finds nothing. The bit is returned in A and Y, with Z set if an object may lie there, and also stored in &8F (victory_pitch), where nothing reads it. map_ptr is left pointing into object_free_map.
|
|||||||||||||||
| ; Point map_ptr at the cell's room in object_free_map. | |||||||||||||||
| 7938 | .test_object_free←2← 70B5 JSR← 7166 JSR | ||||||||||||||
| LDA cell_y ; Room offset = (cell_y AND &F8) x 4 + (cell_x AND &F8)... | |||||||||||||||
| 793B | AND #&f8 ; ...y AND &F8 = 8 x the cell's row of rooms... | ||||||||||||||
| 793D | STA scratch ; ...kept in scratch, to add up four times... | ||||||||||||||
| 7940 | CLC ; ...(y < 64 on the map: no carry, so clear it once) | ||||||||||||||
| 7941 | ADC scratch ; ...doubled: 16 bytes per row of rooms so far... | ||||||||||||||
| 7944 | ADC scratch ; ...tripled: 24... | ||||||||||||||
| 7947 | ADC scratch ; ...x 4: 32 bytes, laid out as room_walls | ||||||||||||||
| 794A | STA map_ptr ; ...the start of its row of rooms, in map_ptr | ||||||||||||||
| 794C | LDA cell_x ; Add the room's column in that row... | ||||||||||||||
| 794F | AND #&f8 ; ...x AND &F8 = 8 x the column: 8 bytes per room | ||||||||||||||
| 7951 | ADC map_ptr ; ...to the row's offset... | ||||||||||||||
| 7953 | STA map_ptr ; ...map_ptr low = the room's offset (0-&B8)... | ||||||||||||||
| 7955 | LDA #>(object_free_map) ; ...in page &21, object_free_map... | ||||||||||||||
| 7957 | STA map_ptr_hi ; ...as map_ptr's high byte: map_ptr = the room's bytes | ||||||||||||||
| ; Pick out the cell's bit, as test_wall does. | |||||||||||||||
| 7959 | LDA cell_x ; Mask for the cell's column within the room... | ||||||||||||||
| 795C | AND #7 ; ...x AND 7, 0 at the left... | ||||||||||||||
| 795E | TAX ; ...in X, to look up its bit... | ||||||||||||||
| 795F | LDA bit_masks,x ; ...&80 for column 0 down to &01 for column 7 | ||||||||||||||
| 7962 | STA scratch ; ...kept in scratch to test the row byte with | ||||||||||||||
| 7965 | LDA cell_y ; The row byte: y AND 7... | ||||||||||||||
| 7968 | AND #7 ; ...the cell's row within the room, 0-7... | ||||||||||||||
| 796A | TAY ; ...in Y, indexing the room's eight bytes | ||||||||||||||
| 796B | LDA (map_ptr),y ; The row's bits, one per cell... | ||||||||||||||
| 796D | AND scratch ; ...masked to this cell: zero if an object may lie | ||||||||||||||
| 7970 | STA victory_pitch ; ...copied to &8F, which is never read for it... | ||||||||||||||
| 7972 | TAY ; ...and to Y: callers pull X, then test Y | ||||||||||||||
| 7973 | RTS ; Return with Z set if an object may lie here | ||||||||||||||
Look for a monster or hero at a cellSay whether a creature stands in a map cell, and if a monster has walked into a hero, hurt the hero. Called by move_heroes and move_missiles for the cell a hero or missile is entering, and by update_monsters for the cell a monster steps into and for the trapdoor a dead monster comes back at (monster_reappears). Monsters 30 to 1 are compared first, skipping monster number scratch; the first whose cell matches is returned. If none matches and scratch is non-zero (a monster is asking), heroes 0 to 3 are compared too, and the first one found loses hero_damage_taken points of health, one at a time through lose_health_point. A hero or missile passes scratch = 0, so only monsters are looked for (they test heroes their own way); a monster passes its own number, so it skips itself and is blocked by, and hurts, a hero in its way, every frame it tries. Neither search looks at state: a dying monster still fills its cell, and a hero out of play (a skull) blocks a monster too, though lose_health_point takes nothing from them. A found monster is reported with A = Y = cell_y, so one in map row 0 would read as nothing found. monster_reappears calls this without loading the trapdoor's cell, so it tests the view position plot_at_cell left in cell_x, cell_y; a hero who happens to stand at that cell is hurt.
|
|||||||||||||||||
| ; Monsters first: any but the asker, alive or dying, in the ; cell? | |||||||||||||||||
| 7974 | .find_creature←4← 6FDC JSR← 713F JSR← 7A8C JSR← 7CE6 JSR | ||||||||||||||||
| LDX #max_monster ; Monsters 30 to 1, alive or dying... | |||||||||||||||||
| 7976 | .check_monster←1← 798E BNE | ||||||||||||||||
| CPX scratch ; ...except monster number scratch, the one asking | |||||||||||||||||
| 7979 | BEQ next_monster_find ; The asker itself: skip it | ||||||||||||||||
| 797B | LDA cell_x ; Is this monster in the cell? cell_x... | ||||||||||||||||
| 797E | CMP monster_x,x ; ...against the monster's x | ||||||||||||||||
| 7981 | BNE next_monster_find ; Another column: not this monster | ||||||||||||||||
| 7983 | LDA cell_y ; ...and cell_y... | ||||||||||||||||
| 7986 | CMP monster_y,x ; ...against the monster's y | ||||||||||||||||
| 7989 | BNE next_monster_find ; Another row: not this monster | ||||||||||||||||
| 798B | TAY ; Found: A = Y = cell_y, X = the monster | ||||||||||||||||
| 798C | RTS ; Return, Z clear unless the cell is in row 0 | ||||||||||||||||
| 798D | .next_monster_find←3← 7979 BEQ← 7981 BNE← 7989 BNE | ||||||||||||||||
| DEX ; Next monster down | |||||||||||||||||
| 798E | BNE check_monster ; Until monster 1 is done | ||||||||||||||||
| ; Then, only for a monster asking, heroes: the first in the ; cell, in play or not, is hurt and blocks the move. | |||||||||||||||||
| 7990 | LDA scratch ; No monster there. Is a monster asking (scratch > 0)? | ||||||||||||||||
| 7993 | BEQ nothing_found ; No (a hero or missile): heroes are not looked for | ||||||||||||||||
| 7995 | LDX #0 ; Yes: a hero blocks it too. Heroes 0 to 3... | ||||||||||||||||
| 7997 | .check_hero←1← 79BA BNE | ||||||||||||||||
| LDA cell_x ; ...is this hero in the cell? cell_x... | |||||||||||||||||
| 799A | CMP hero_x,x ; ...against the hero's x | ||||||||||||||||
| 799D | BNE next_hero_find ; Another column: not this hero | ||||||||||||||||
| 799F | LDA cell_y ; ...and cell_y... | ||||||||||||||||
| 79A2 | CMP hero_y,x ; ...against the hero's y | ||||||||||||||||
| 79A5 | BNE next_hero_find ; Another row: not this hero | ||||||||||||||||
| 79A7 | LDY hero_damage_taken,x ; Found, in play or not: health a blow costs them | ||||||||||||||||
| 79AA | .take_hero_damage←1← 79B2 BNE | ||||||||||||||||
| TYA ; Take it a point at a time: keep the points left... | |||||||||||||||||
| 79AB | PHA ; ...on the stack across lose_health_point | ||||||||||||||||
| 79AC | JSR lose_health_point ; One point off the hero (none if out of play) | ||||||||||||||||
| 79AF | PLA ; Recover the points still to take... | ||||||||||||||||
| 79B0 | TAY ; ...back in Y | ||||||||||||||||
| 79B1 | DEY ; One point fewer to take | ||||||||||||||||
| 79B2 | BNE take_hero_damage ; Until the hero has taken them all | ||||||||||||||||
| 79B4 | LDA #1 ; Return A = 1, Z clear (Y = 0): a hero was there | ||||||||||||||||
| 79B6 | RTS ; ...so the monster is blocked (or parked) | ||||||||||||||||
| 79B7 | .next_hero_find←2← 799D BNE← 79A5 BNE | ||||||||||||||||
| INX ; Next hero up | |||||||||||||||||
| 79B8 | CPX #4 ; All four heroes checked? | ||||||||||||||||
| 79BA | BNE check_hero ; No: check the next | ||||||||||||||||
| 79BC | .nothing_found←1← 7993 BEQ | ||||||||||||||||
| LDA #0 ; Nothing there: return A = Y = 0... | |||||||||||||||||
| 79BE | LDY #0 ; ...the cell is free of creatures | ||||||||||||||||
| 79C0 | RTS ; Return with Z set: nothing in the cell | ||||||||||||||||
Draw the trapdoors and move the monstersMove every monster on by one frame of its life, and redraw the trapdoors they come out of. update_game calls it once a frame, after draw_objects and move_missiles, so a monster killed by a missile or magic this frame starts its death here. The eight trapdoors are drawn first, because erasing a creature or missile that crossed one has blanked its cell. They are drawn over whatever stands on them, so a hero or missile on a trapdoor is overdrawn by it every frame. Then each monster, 30 down to 1, is erased where it was drawn last frame and moved on according to its state. Moving: a monster mid-step slides a quarter cell further (continue_monster_step). One that is not stepping tries the next cell the way it faces. If that cell is open and holds no creature, it starts a step: monster_x and monster_y keep the old cell while the offsets carry the sprite across, so an interior cell takes four frames (a quarter, a half, three quarters, then square in the new cell). A cell in a room's edge row or column, in the direction of travel, is entered at once, so no sprite is drawn between two rooms and a monster crosses from one room into the next in two frames. Blocked: a wall, a closed door or a creature in the cell keeps the monster where it is. It turns a random way, each of the four equally likely, from the System VIA's timer 1, and tries that way next frame. A monster does not chase anyone: it walks straight on until blocked. find_creature takes hero_damage_taken points from a hero it finds in the cell, so a monster hurts a hero each time it tries to step into them. Dying: a monster killed by a missile or by magic is given sprite &15 (the blank) there. Each frame here advances it through the sparkles &16-&19, drawn where it died. Reappearing: after the last sparkle monster_reappears puts it on the next trapdoor in turn, facing up, to be drawn next frame. reset_monsters starts every monster at the blank with x &FF, so at the start of a level all 30 sparkle off the map together and emerge on the same frame, shared out round the eight trapdoors in turn. Only the target cell is ever tested for a creature: during a slide the monster is still recorded in the cell it is leaving, and the arrival is not checked again, so two monsters, or a monster and a hero, can end a step in the same cell. The creature test made as a monster reappears looks at the wrong cell (see monster_reappears).
|
||||||||
| 79C1 | .update_monsters←1← 1ED4 JSR | |||||||
| LDX #8 ; Redraw trapdoors 8 to 1 (sprite &2C)... | ||||||||
| 79C3 | LDA #0 ; Trapdoors sit squarely in their cells: | |||||||
| 79C5 | STA plot_offset_x ; ...no horizontal offset... | |||||||
| 79C7 | STA plot_offset_y ; ...and no vertical offset | |||||||
| 79C9 | LDA #spr_trapdoor ; The trapdoor sprite... | |||||||
| 79CB | STA sprite_number ; ...the same for all eight | |||||||
| 79CD | .draw_trapdoor←1← 79E1 BNE | |||||||
| LDA trapdoor_x - 1,x ; This trapdoor's map x... | ||||||||
| 79D0 | STA cell_x ; ...as the cell to plot | |||||||
| 79D3 | LDA trapdoor_y - 1,x ; ...and its map y | |||||||
| 79D6 | STA cell_y ; ...as cell_y | |||||||
| 79D9 | TXA ; Keep the trapdoor number... | |||||||
| 79DA | PHA ; ...on the stack: plot_at_cell changes X | |||||||
| 79DB | JSR plot_at_cell ; Draw it in every view showing its cell | |||||||
| 79DE | PLA ; Recover the trapdoor number... | |||||||
| 79DF | TAX ; ...back in X | |||||||
| 79E0 | DEX ; Next trapdoor down | |||||||
| 79E1 | BNE draw_trapdoor ; Until trapdoor 1 is drawn | |||||||
| 79E3 | LDX #max_monster ; Then each monster, 30 to 1... | |||||||
| ; Each monster in turn, 30 down to 1. It is first rubbed out ; where it was drawn last frame, its cell and offsets plotted ; with the blank sprite, and its cell is kept in previous_x and ; previous_y. Then its state decides what happens: a dying ; monster (sprite &15 and up) shows its next sparkle, one part ; way through a step slides on, and any other tries a new step. ; The monster number stays on the stack until monster_done. | ||||||||
| 79E5 | .next_monster_update←1← 7B2D JMP | |||||||
| TXA ; Keep the monster number... | ||||||||
| 79E6 | PHA ; ...on the stack while it moves | |||||||
| 79E7 | LDA monster_x,x ; Erase it at its cell and offsets, remembering the cell | |||||||
| 79EA | STA cell_x ; ...as the cell to erase... | |||||||
| 79ED | STA previous_x ; ...and as where it came from | |||||||
| 79F0 | LDA monster_y,x ; ...and its map y... | |||||||
| 79F3 | STA cell_y ; ...as the cell to erase... | |||||||
| 79F6 | STA previous_y ; ...and as where it came from | |||||||
| 79F9 | LDA #spr_blank ; The blank sprite... | |||||||
| 79FB | STA sprite_number ; ...to rub it out | |||||||
| 79FD | LDA monster_offset_x,x ; Its horizontal offset... | |||||||
| 7A00 | STA plot_offset_x ; ...for the erase | |||||||
| 7A02 | LDA monster_offset_y,x ; ...and its vertical offset... | |||||||
| 7A05 | STA plot_offset_y ; ...so the blank covers it where it was drawn | |||||||
| 7A07 | JSR plot_at_cell ; Rub the monster out in every view showing it | |||||||
| 7A0A | PLA ; The monster number back from the stack... | |||||||
| 7A0B | PHA ; ...left there for monster_done | |||||||
| 7A0C | TAX ; ...in X again | |||||||
| 7A0D | LDA monster_sprite,x ; Is the monster dying? | |||||||
| 7A10 | CMP #spr_blank ; Sprite &15 (the blank) and up: killed | |||||||
| 7A12 | BCC check_monster_step ; Below &15: alive, so it moves | |||||||
| 7A14 | JMP advance_dying_monster ; Killed: show its next sparkle | |||||||
| 7A17 | .check_monster_step←1← 7A12 BCC | |||||||
| LDA monster_step,x ; Part way through a step? | ||||||||
| 7A1A | BEQ start_monster_move ; No: try a step to the next cell | |||||||
| 7A1C | JSR continue_monster_step ; Yes: slide it a quarter cell further | |||||||
| 7A1F | PLA ; Drop the stacked number (X still has it)... | |||||||
| 7A20 | JMP draw_monster ; ...as draw_monster pushes it again | |||||||
| ; A monster that is not stepping tries the next cell the way it ; faces. Its cell is moved there provisionally and the step's ; first offsets are set, then the cell is tested: first for a ; wall or closed door, then for a creature. | ||||||||
| 7A23 | .start_monster_move←1← 7A1A BEQ | |||||||
| LDA monster_sprite,x ; Step into the next cell in the way it faces: up... | ||||||||
| 7A26 | CMP #spr_monster_up_0 ; Sprite 9, facing up? | |||||||
| 7A28 | BNE monster_right ; No: try right | |||||||
| 7A2A | DEC monster_y,x ; Yes: one row up | |||||||
| 7A2D | .monster_right←1← 7A28 BNE | |||||||
| CMP #spr_monster_right_0 ; Sprite &0B, facing right? | ||||||||
| 7A2F | BNE monster_down ; No: try down | |||||||
| 7A31 | INC monster_x,x ; Yes: one column right | |||||||
| 7A34 | .monster_down←1← 7A2F BNE | |||||||
| CMP #spr_monster_down_0 ; Sprite &0D, facing down? | ||||||||
| 7A36 | BNE monster_left ; No: try left | |||||||
| 7A38 | INC monster_y,x ; Yes: one row down | |||||||
| 7A3B | .monster_left←1← 7A36 BNE | |||||||
| CMP #spr_monster_left_0 ; Sprite &0F, facing left? | ||||||||
| 7A3D | BNE set_monster_step ; No: it does not move | |||||||
| 7A3F | DEC monster_x,x ; Yes: one column left | |||||||
| 7A42 | .set_monster_step←1← 7A3D BNE | |||||||
| JSR start_monster_step ; First quarter-cell offsets of the step | ||||||||
| 7A45 | LDA monster_x,x ; Is the new cell a wall (or a closed door)? | |||||||
| 7A48 | STA cell_x ; ...the new x as cell_x | |||||||
| 7A4B | LDA monster_y,x ; The new y... | |||||||
| 7A4E | STA cell_y ; ...as cell_y: the cell to test | |||||||
| 7A51 | JSR test_wall ; Z set if the cell is open | |||||||
| 7A54 | BEQ check_monster_blocked ; Open: is a creature in the way? | |||||||
| ; Blocked by a wall: the monster goes back to the cell it was ; in, with no step under way, and faces a random way. A random ; 0-7 + 8 gives a sprite &08-&0F; an even one is rounded up to ; the facing above it, so up, right, down and left are each ; chosen 2 times in 8. It tries that way on the next frame. | ||||||||
| 7A56 | PLA ; Wall: the monster stays where it is... | |||||||
| 7A57 | TAX ; ...its number back in X, which test_wall changed | |||||||
| 7A58 | LDA previous_x ; The cell it was in... | |||||||
| 7A5B | STA monster_x,x ; ...back in monster_x | |||||||
| 7A5E | LDA previous_y ; ...and its row... | |||||||
| 7A61 | STA monster_y,x ; ...back in monster_y | |||||||
| 7A64 | LDA #0 ; No step under way: | |||||||
| 7A66 | STA monster_step,x ; ...step count 0 | |||||||
| 7A69 | STA monster_offset_x,x ; ...no horizontal offset | |||||||
| 7A6C | STA monster_offset_y,x ; ...no vertical offset | |||||||
| 7A6F | LDA system_via_t1c_l ; Turn a random way, from the System VIA's timer | |||||||
| 7A72 | AND #7 ; A random 0-7... | |||||||
| 7A74 | CLC ; ...+ 8, the first monster sprite... | |||||||
| 7A75 | ADC #8 ; ...a sprite &08-&0F | |||||||
| 7A77 | STA monster_sprite,x ; Face the monster that way | |||||||
| 7A7A | AND #1 ; Odd sprites (9, &0B, &0D, &0F) are the facings | |||||||
| 7A7C | BEQ turn_monster ; Even: round it up to the next facing | |||||||
| 7A7E | JMP draw_monster ; Odd: draw it; it tries the new way next frame | |||||||
| 7A81 | .turn_monster←1← 7A7C BEQ | |||||||
| INC monster_sprite,x ; Round up: each way is equally likely, 2 in 8 | ||||||||
| 7A84 | JMP draw_monster ; Draw it; it tries the new way next frame | |||||||
| ; The cell is open: is a monster or hero standing in it? ; find_creature skips this monster and, because scratch is ; non-zero, takes hero_damage_taken points from a hero it finds ; there. A monster mid-slide is still recorded in the cell it is ; leaving, so it does not block the cell it is entering. | ||||||||
| 7A87 | .check_monster_blocked←1← 7A54 BEQ | |||||||
| PLA ; Monster or hero in the new cell? (a hero there is hurt) | ||||||||
| 7A88 | PHA ; ...left stacked for later | |||||||
| 7A89 | STA scratch ; Non-zero scratch: skip this monster, check heroes | |||||||
| 7A8C | JSR find_creature ; A = 0 if no creature is at cell_x, cell_y | |||||||
| 7A8F | CMP #0 ; Non-zero: a monster or hero is in the cell | |||||||
| 7A91 | BEQ monster_vertical ; No: the cell is free, so the step goes ahead | |||||||
| ; Blocked by a creature: as for a wall, the monster stays where ; it was, with no step, and turns a random way. | ||||||||
| 7A93 | PLA ; Yes: stay put, with no step, and turn a random way | |||||||
| 7A94 | TAX ; ...its number back in X, which find_creature changed | |||||||
| 7A95 | LDA previous_x ; The cell it was in... | |||||||
| 7A98 | STA monster_x,x ; ...back in monster_x | |||||||
| 7A9B | LDA previous_y ; ...and its row... | |||||||
| 7A9E | STA monster_y,x ; ...back in monster_y | |||||||
| 7AA1 | LDA #0 ; No step under way: | |||||||
| 7AA3 | STA monster_step,x ; ...step count 0 | |||||||
| 7AA6 | STA monster_offset_x,x ; ...no horizontal offset | |||||||
| 7AA9 | STA monster_offset_y,x ; ...no vertical offset | |||||||
| 7AAC | LDA system_via_t1c_l ; Turn a random way, from the System VIA's timer | |||||||
| 7AAF | AND #7 ; A random 0-7... | |||||||
| 7AB1 | CLC ; ...+ 8, the first monster sprite... | |||||||
| 7AB2 | ADC #8 ; ...a sprite &08-&0F | |||||||
| 7AB4 | STA monster_sprite,x ; Face the monster that way | |||||||
| 7AB7 | AND #1 ; Odd sprites (9, &0B, &0D, &0F) are the facings | |||||||
| 7AB9 | BNE draw_monster ; Odd: draw it; it tries the new way next frame | |||||||
| 7ABB | INC monster_sprite,x ; Even: round it up to the next facing | |||||||
| 7ABE | JMP draw_monster ; Draw it; it tries the new way next frame | |||||||
| ; The step goes ahead. A step into a cell on a room's edge row ; (moving up or down) or edge column (moving across) is made at ; once, with no slide, so the sprite is never drawn part way ; between two rooms. Any other step keeps the old cell in ; monster_x and monster_y and lets the offsets carry the sprite ; across over four frames. | ||||||||
| 7AC1 | .monster_vertical←1← 7A91 BEQ | |||||||
| PLA ; The step goes ahead... | ||||||||
| 7AC2 | TAX ; ...its number back in X, which find_creature changed | |||||||
| 7AC3 | LDA monster_sprite,x ; Which way is it going? | |||||||
| 7AC6 | CMP #spr_monster_up_0 ; Moving up, so the new row decides? | |||||||
| 7AC8 | BEQ check_room_edge ; Yes: check the new row | |||||||
| 7ACA | CMP #spr_monster_down_0 ; Moving down, likewise? | |||||||
| 7ACC | BEQ check_room_edge ; Yes: check the new row | |||||||
| 7ACE | LDA monster_x,x ; Across: is the new cell in a room's edge column? | |||||||
| 7AD1 | AND #7 ; Column within its eight-cell room | |||||||
| 7AD3 | BEQ monster_at_edge ; Column 0: the left edge | |||||||
| 7AD5 | CMP #7 ; Column 7, the right edge? | |||||||
| 7AD7 | BEQ monster_at_edge ; Yes: an edge | |||||||
| 7AD9 | JMP monster_move_on ; No: slide there over the coming frames | |||||||
| 7ADC | .check_room_edge←2← 7AC8 BEQ← 7ACC BEQ | |||||||
| LDA monster_y,x ; Up or down: is the new cell in a room's edge row? | ||||||||
| 7ADF | AND #7 ; Row within its eight-cell room | |||||||
| 7AE1 | BEQ monster_at_edge ; Row 0: the top edge | |||||||
| 7AE3 | CMP #7 ; Row 7, the bottom edge? | |||||||
| 7AE5 | BEQ monster_at_edge ; Yes: an edge | |||||||
| 7AE7 | JMP monster_move_on ; No: slide there over the coming frames | |||||||
| 7AEA | .monster_at_edge←4← 7AD3 BEQ← 7AD7 BEQ← 7AE1 BEQ← 7AE5 BEQ | |||||||
| LDA #0 ; Edge: jump straight in, so no slide crosses rooms | ||||||||
| 7AEC | STA monster_step,x ; ...step count 0 | |||||||
| 7AEF | STA monster_offset_x,x ; ...no horizontal offset | |||||||
| 7AF2 | STA monster_offset_y,x ; ...no vertical offset | |||||||
| 7AF5 | JMP draw_monster ; Draw it squarely in the new cell | |||||||
| 7AF8 | .monster_move_on←2← 7AD9 JMP← 7AE7 JMP | |||||||
| LDA previous_x ; Slide: keep the old cell until the step ends... | ||||||||
| 7AFB | STA monster_x,x ; ...back in monster_x | |||||||
| 7AFE | LDA previous_y ; ...and its row... | |||||||
| 7B01 | STA monster_y,x ; ...back in monster_y: drawn offset from there | |||||||
| ; Draw the monster at its recorded cell, displaced by its ; offsets, as its facing sprite plus its walking frame, in every ; view that shows the room. The dying and reappearing paths join ; at monster_done, which pulls the monster number and moves on ; to the next. | ||||||||
| 7B04 | .draw_monster←6← 7A20 JMP← 7A7E JMP← 7A84 JMP← 7AB9 BNE← 7ABE JMP← 7AF5 JMP | |||||||
| LDA monster_x,x ; Draw it: its cell, facing + frame, offsets | ||||||||
| 7B07 | STA cell_x ; ...as cell_x for plot_at_cell | |||||||
| 7B0A | LDA monster_y,x ; Its map y... | |||||||
| 7B0D | STA cell_y ; ...as cell_y for plot_at_cell | |||||||
| 7B10 | CLC ; Ready to add the frame | |||||||
| 7B11 | LDA monster_sprite,x ; Its facing sprite... | |||||||
| 7B14 | ADC monster_frame,x ; ...plus walking frame 0 or 1... | |||||||
| 7B17 | STA sprite_number ; ...is the sprite to plot | |||||||
| 7B19 | LDA monster_offset_x,x ; How far it has slid across... | |||||||
| 7B1C | STA plot_offset_x ; ...as the horizontal offset | |||||||
| 7B1E | LDA monster_offset_y,x ; How far it has slid down... | |||||||
| 7B21 | STA plot_offset_y ; ...as the vertical offset | |||||||
| 7B23 | TXA ; Keep the monster number... | |||||||
| 7B24 | PHA ; ...across the plot, which changes X | |||||||
| 7B25 | JSR plot_at_cell ; Draw it in every view whose room shows it | |||||||
| 7B28 | .monster_done←3← 7B5F JMP← 7CF8 JMP← 7CFB JMP | |||||||
| PLA ; The monster number back from the stack... | ||||||||
| 7B29 | TAX ; ...in X, to count on down | |||||||
| 7B2A | DEX ; Next monster down | |||||||
| 7B2B | BEQ update_monsters_done ; Past monster 1: all 30 updated | |||||||
| 7B2D | JMP next_monster_update ; Otherwise update the next one | |||||||
| 7B30 | .update_monsters_done←1← 7B2B BEQ | |||||||
| RTS ; Return: every monster moved and drawn | ||||||||
| ; A killed monster is set to sprite &15 (the blank). Each frame ; the sprite advances, showing the sparkles &16-&19 at the cell ; and offsets it died at; after the last the monster reappears. ; Its step counter is left as it was, since a dying monster is ; dispatched before the step is looked at. | ||||||||
| 7B31 | .advance_dying_monster←1← 7A14 JMP | |||||||
| PLA ; Drop the stacked number (X still has it) | ||||||||
| 7B32 | INC monster_sprite,x ; Next death frame: &16-&19 are the sparkles | |||||||
| 7B35 | LDA monster_sprite,x ; Which frame now? | |||||||
| 7B38 | CMP #spr_sparkle_3 + 1 ; Past the last sparkle (&19)? | |||||||
| 7B3A | BNE draw_monster_death ; No: draw this sparkle | |||||||
| 7B3C | JMP monster_reappears ; Yes: bring it back at a trapdoor | |||||||
| 7B3F | .draw_monster_death←1← 7B3A BNE | |||||||
| TXA ; Draw the sparkle where the monster died... | ||||||||
| 7B40 | PHA ; ...keeping the monster number across the plot | |||||||
| 7B41 | LDA monster_x,x ; Its map x, where it died... | |||||||
| 7B44 | STA cell_x ; ...as cell_x for plot_at_cell | |||||||
| 7B47 | LDA monster_y,x ; ...and its map y... | |||||||
| 7B4A | STA cell_y ; ...as cell_y for plot_at_cell | |||||||
| 7B4D | LDA monster_sprite,x ; The sparkle sprite, with no walking frame... | |||||||
| 7B50 | STA sprite_number ; ...is the sprite to plot | |||||||
| 7B52 | LDA monster_offset_x,x ; Offsets frozen at the moment it died... | |||||||
| 7B55 | STA plot_offset_x ; ...across, as plot_offset_x | |||||||
| 7B57 | LDA monster_offset_y,x ; ...and how far down it had slid... | |||||||
| 7B5A | STA plot_offset_y ; ...so it sparkles exactly where it died | |||||||
| 7B5C | JSR plot_at_cell ; Draw the sparkle in every view showing it | |||||||
| 7B5F | JMP monster_done ; Pull the monster number and on to the next | |||||||
Start a hero's step between cellsCalled by move_heroes when a direction key starts a move within a room and the hero has no Boots of Speed. Set hero X's step counter to 1 and their pixel offsets to half a cell in the direction they face (hero_direction 1, 3, 5 or 7: up, right, down, left): 6 rows up or down, or 2 byte columns left or right. move_heroes then draws the hero there, half way to the next cell, for one frame, still recorded in the old cell; continue_hero_step completes the move on the next frame.
|
|||||||||
| 7B62 | .start_hero_step←4← 6ECE JSR← 6EE1 JSR← 6EF4 JSR← 6F07 JSR | ||||||||
| LDA #1 ; One frame to go before the hero is in the new cell | |||||||||
| 7B64 | STA hero_step,x ; ...as hero_step: continue_hero_step ends it | ||||||||
| 7B67 | LDA hero_direction,x ; Draw the hero half a cell along the way they face | ||||||||
| 7B6A | CMP #1 ; Direction 1, facing up? | ||||||||
| 7B6C | BNE hero_step_right ; No: try right | ||||||||
| 7B6E | LDA #0 ; Up: not across... | ||||||||
| 7B70 | STA hero_offset_x,x ; ...no horizontal offset | ||||||||
| 7B73 | LDA #&fa ; -6: half a 12-row cell up... | ||||||||
| 7B75 | STA hero_offset_y,x ; ...as the vertical offset | ||||||||
| 7B78 | RTS ; Return: drawn half a cell up | ||||||||
| 7B79 | .hero_step_right←1← 7B6C BNE | ||||||||
| CMP #3 ; Direction 3, facing right? | |||||||||
| 7B7B | BNE hero_step_down ; No: try down | ||||||||
| 7B7D | LDA #0 ; Right: not up or down... | ||||||||
| 7B7F | STA hero_offset_y,x ; ...no vertical offset | ||||||||
| 7B82 | LDA #2 ; +2: half a 4-byte cell right... | ||||||||
| 7B84 | STA hero_offset_x,x ; ...as the horizontal offset | ||||||||
| 7B87 | RTS ; Return: drawn half a cell right | ||||||||
| 7B88 | .hero_step_down←1← 7B7B BNE | ||||||||
| CMP #5 ; Direction 5, facing down? | |||||||||
| 7B8A | BNE hero_step_left ; No: they face left | ||||||||
| 7B8C | LDA #0 ; Down: not across... | ||||||||
| 7B8E | STA hero_offset_x,x ; ...no horizontal offset | ||||||||
| 7B91 | LDA #6 ; +6: half a cell down... | ||||||||
| 7B93 | STA hero_offset_y,x ; ...as the vertical offset | ||||||||
| 7B96 | RTS ; Return: drawn half a cell down | ||||||||
| 7B97 | .hero_step_left←1← 7B8A BNE | ||||||||
| LDA #0 ; Left: not up or down... | |||||||||
| 7B99 | STA hero_offset_y,x ; ...no vertical offset | ||||||||
| 7B9C | LDA #&fe ; -2: half a cell left... | ||||||||
| 7B9E | STA hero_offset_x,x ; ...as the horizontal offset | ||||||||
| 7BA1 | RTS ; Return: drawn half a cell left | ||||||||
Continue a hero's step between cellsCalled by move_heroes, in place of reading the hero's keys, on the frame after a step starts. Toggle hero X's walking frame and count down their step. When it ends, move the hero one cell in the direction they face and clear the pixel offsets, so a step takes two frames. The offsets are then doubled. Since start_hero_step sets the counter to 1 and nothing else gives an in-play hero a non-zero step, the step always ends here, so the doubling only ever doubles zero offsets.
|
|||||||||
| 7BA2 | .continue_hero_step←1← 6EB4 JSR | ||||||||
| LDA hero_frame,x ; Swap the hero's walking frame... | |||||||||
| 7BA5 | EOR #1 ; ...0 to 1 or 1 to 0... | ||||||||
| 7BA7 | STA hero_frame,x ; ...so their legs move | ||||||||
| 7BAA | DEC hero_step,x ; One frame fewer to the new cell | ||||||||
| 7BAD | BNE double_offsets ; Not there yet (never taken: the step is 1) | ||||||||
| 7BAF | LDA hero_direction,x ; Arrived: move their cell on the way they face: up... | ||||||||
| 7BB2 | CMP #1 ; Direction 1, facing up? | ||||||||
| 7BB4 | BNE continue_right ; No: try right | ||||||||
| 7BB6 | DEC hero_y,x ; Yes: one row up | ||||||||
| 7BB9 | .continue_right←1← 7BB4 BNE | ||||||||
| CMP #3 ; Direction 3, facing right? | |||||||||
| 7BBB | BNE continue_down ; No: try down | ||||||||
| 7BBD | INC hero_x,x ; Yes: one column right | ||||||||
| 7BC0 | .continue_down←1← 7BBB BNE | ||||||||
| CMP #5 ; Direction 5, facing down? | |||||||||
| 7BC2 | BNE continue_left ; No: try left | ||||||||
| 7BC4 | INC hero_y,x ; Yes: one row down | ||||||||
| 7BC7 | .continue_left←1← 7BC2 BNE | ||||||||
| CMP #7 ; Direction 7, facing left? | |||||||||
| 7BC9 | BNE hero_no_offsets ; No: no move | ||||||||
| 7BCB | DEC hero_x,x ; Yes: one column left | ||||||||
| 7BCE | .hero_no_offsets←1← 7BC9 BNE | ||||||||
| LDA #0 ; Drawn squarely in the new cell: | |||||||||
| 7BD0 | STA hero_offset_x,x ; ...no horizontal offset | ||||||||
| 7BD3 | STA hero_offset_y,x ; ...no vertical offset | ||||||||
| 7BD6 | .double_offsets←1← 7BAD BNE | ||||||||
| CLC ; Double the offsets, which are always zero by now | |||||||||
| 7BD7 | LDA hero_offset_x,x ; Horizontal offset x 2: the offset... | ||||||||
| 7BDA | ADC hero_offset_x,x ; ...added to itself... | ||||||||
| 7BDD | STA hero_offset_x,x ; ...stored back, still 0 | ||||||||
| 7BE0 | CLC ; Ready for the vertical offset | ||||||||
| 7BE1 | LDA hero_offset_y,x ; Vertical offset x 2: the offset... | ||||||||
| 7BE4 | ADC hero_offset_y,x ; ...added to itself... | ||||||||
| 7BE7 | STA hero_offset_y,x ; ...stored back, still 0 | ||||||||
| 7BEA | RTS ; Return: the hero is squarely in the new cell | ||||||||
Start a monster's step between cellsCalled by update_monsters when a monster that is not stepping tries the next cell, before that cell is tested. Set monster X's step counter to 3 and its offsets to the first quarter of a cell in the direction it faces: 3 rows up or down, or one byte column left or right. If the cell turns out to be blocked, or on a room's edge, update_monsters clears all three again; otherwise the monster is drawn this frame a quarter of the way there, and continue_monster_step takes over on the next.
|
|||||||||
| 7BEB | .start_monster_step←1← 7A42 JSR | ||||||||
| LDA #3 ; Three more frames to reach the new cell... | |||||||||
| 7BED | STA monster_step,x ; ...as the step count | ||||||||
| 7BF0 | LDA monster_sprite,x ; Draw it a quarter cell along the way it faces: up... | ||||||||
| 7BF3 | CMP #spr_monster_up_0 ; Sprite 9, facing up? | ||||||||
| 7BF5 | BNE monster_step_right ; No: try right | ||||||||
| 7BF7 | LDA #0 ; Up: not across... | ||||||||
| 7BF9 | STA monster_offset_x,x ; ...no horizontal offset | ||||||||
| 7BFC | LDA #&fd ; -3: a quarter of a 12-row cell up... | ||||||||
| 7BFE | STA monster_offset_y,x ; ...as the vertical offset | ||||||||
| 7C01 | RTS ; Return: drawn a quarter cell up | ||||||||
| 7C02 | .monster_step_right←1← 7BF5 BNE | ||||||||
| CMP #spr_monster_right_0 ; Sprite &0B, facing right? | |||||||||
| 7C04 | BNE monster_step_down ; No: try down | ||||||||
| 7C06 | LDA #0 ; Right: not up or down... | ||||||||
| 7C08 | STA monster_offset_y,x ; ...no vertical offset | ||||||||
| 7C0B | LDA #1 ; +1: a quarter of a 4-byte cell right... | ||||||||
| 7C0D | STA monster_offset_x,x ; ...as the horizontal offset | ||||||||
| 7C10 | RTS ; Return: drawn a quarter cell right | ||||||||
| 7C11 | .monster_step_down←1← 7C04 BNE | ||||||||
| CMP #spr_monster_down_0 ; Sprite &0D, facing down? | |||||||||
| 7C13 | BNE monster_step_left ; No: it faces left | ||||||||
| 7C15 | LDA #0 ; Down: not across... | ||||||||
| 7C17 | STA monster_offset_x,x ; ...no horizontal offset | ||||||||
| 7C1A | LDA #3 ; +3: a quarter of a cell down... | ||||||||
| 7C1C | STA monster_offset_y,x ; ...as the vertical offset | ||||||||
| 7C1F | RTS ; Return: drawn a quarter cell down | ||||||||
| 7C20 | .monster_step_left←1← 7C13 BNE | ||||||||
| LDA #0 ; Left: not up or down... | |||||||||
| 7C22 | STA monster_offset_y,x ; ...no vertical offset | ||||||||
| 7C25 | LDA #&ff ; -1: a quarter of a cell left... | ||||||||
| 7C27 | STA monster_offset_x,x ; ...as the horizontal offset | ||||||||
| 7C2A | RTS ; Return: drawn a quarter cell left | ||||||||
Continue a monster's step between cellsCalled by update_monsters each frame while monster X's step is under way (monster_step non-zero). Toggle its walking frame, so its legs move, and count down its step. On the first two calls the offsets grow by another quarter of a cell (a byte column or three rows), to a half and then three quarters. On the third the step ends: monster_x or monster_y moves one cell on the way it faces and the offsets are cleared, so it is drawn squarely in the new cell. With the frame start_monster_step began, a monster crosses an interior cell in four frames. Nothing tests the new cell again on arrival.
|
|||||||||
| 7C2B | .continue_monster_step←1← 7A1C JSR | ||||||||
| LDA monster_frame,x ; Swap the monster's walking frame... | |||||||||
| 7C2E | EOR #1 ; ...0 to 1 or 1 to 0... | ||||||||
| 7C30 | STA monster_frame,x ; ...so its legs move as it slides | ||||||||
| 7C33 | DEC monster_step,x ; One frame fewer to the new cell | ||||||||
| 7C36 | BNE grow_offset_x ; Not there yet: slide a quarter cell further | ||||||||
| 7C38 | LDA monster_sprite,x ; Arrived: move its cell on the way it faces: up... | ||||||||
| 7C3B | CMP #spr_monster_up_0 ; Sprite 9, facing up? | ||||||||
| 7C3D | BNE monster_continue_right ; No: try right | ||||||||
| 7C3F | DEC monster_y,x ; Yes: one row up | ||||||||
| 7C42 | .monster_continue_right←1← 7C3D BNE | ||||||||
| CMP #spr_monster_right_0 ; Sprite &0B, facing right? | |||||||||
| 7C44 | BNE monster_continue_down ; No: try down | ||||||||
| 7C46 | INC monster_x,x ; Yes: one column right | ||||||||
| 7C49 | .monster_continue_down←1← 7C44 BNE | ||||||||
| CMP #spr_monster_down_0 ; Sprite &0D, facing down? | |||||||||
| 7C4B | BNE monster_continue_left ; No: try left | ||||||||
| 7C4D | INC monster_y,x ; Yes: one row down | ||||||||
| 7C50 | .monster_continue_left←1← 7C4B BNE | ||||||||
| CMP #spr_monster_left_0 ; Sprite &0F, facing left? | |||||||||
| 7C52 | BNE monster_no_offsets ; No: no move | ||||||||
| 7C54 | DEC monster_x,x ; Yes: one column left | ||||||||
| 7C57 | .monster_no_offsets←1← 7C52 BNE | ||||||||
| LDA #0 ; Drawn squarely in the new cell: | |||||||||
| 7C59 | STA monster_offset_x,x ; ...no horizontal offset | ||||||||
| 7C5C | STA monster_offset_y,x ; ...no vertical offset (zeros don't grow) | ||||||||
| 7C5F | .grow_offset_x←1← 7C36 BNE | ||||||||
| LDA monster_offset_x,x ; Slide across a further quarter cell (a byte column) | |||||||||
| 7C62 | BEQ grow_offset_y ; Zero: moving up or down, or arrived | ||||||||
| 7C64 | BPL grow_offset_x_right ; Positive: moving right | ||||||||
| 7C66 | DEC monster_offset_x,x ; Negative: one more column left | ||||||||
| 7C69 | JMP grow_offset_y ; Now the vertical offset | ||||||||
| 7C6C | .grow_offset_x_right←1← 7C64 BPL | ||||||||
| INC monster_offset_x,x ; One more column right | |||||||||
| 7C6F | .grow_offset_y←2← 7C62 BEQ← 7C69 JMP | ||||||||
| LDA monster_offset_y,x ; Slide down or up a further quarter cell (3 rows) | |||||||||
| 7C72 | BEQ monster_step_done ; Zero: moving across, or arrived | ||||||||
| 7C74 | BPL grow_offset_y_down ; Positive: moving down | ||||||||
| 7C76 | SEC ; Moving up: three more rows up... | ||||||||
| 7C77 | LDA monster_offset_y,x ; ...from the vertical offset... | ||||||||
| 7C7A | SBC #3 ; ...three rows further up... | ||||||||
| 7C7C | STA monster_offset_y,x ; ...to -6 or -9 | ||||||||
| 7C7F | JMP monster_step_done ; Offsets grown: return | ||||||||
| 7C82 | .grow_offset_y_down←1← 7C74 BPL | ||||||||
| CLC ; Moving down: three more rows down... | |||||||||
| 7C83 | LDA monster_offset_y,x ; ...from the vertical offset... | ||||||||
| 7C86 | ADC #3 ; ...three rows further down... | ||||||||
| 7C88 | STA monster_offset_y,x ; ...to 6 or 9 | ||||||||
| 7C8B | .monster_step_done←2← 7C72 BEQ← 7C7F JMP | ||||||||
| RTS ; Return: offsets grown, or the step ended | |||||||||
| 7C8C | EQUB &DE, &35, &0D, &BD, &35, &0D, &D0, &00, ; Not &60 ; referenced | ||||||||
Test whether a key is pressedReport whether one key is held down at this moment. read_hero_keys calls it for each hero's direction and fire keys, from the hero_key tables, and check_magic for the Ranger's and Magic-User's magic keys. The key is scanned with OSBYTE &81 and a negative INKEY number (Y = &FF), which returns X = Y = &FF if it is held; the caller's X, the hero number, is kept on the stack across the call.
|
|||||||||||||
| 7C95 | .test_key←6← 6EC4 JSR← 6ED7 JSR← 6EEA JSR← 6EFD JSR← 6F10 JSR← 7627 JSR | ||||||||||||
| TAY ; Park the INKEY number in Y for a moment | |||||||||||||
| 7C96 | TXA ; Keep the caller's X (the hero number)... | ||||||||||||
| 7C97 | PHA ; ...on the stack, as OSBYTE returns in X | ||||||||||||
| 7C98 | TYA ; The INKEY number... | ||||||||||||
| 7C99 | TAX ; ...in X, as OSBYTE &81 wants it | ||||||||||||
| 7C9A | LDA #osbyte_inkey ; OSBYTE &81 with Y = &FF: scan the key | ||||||||||||
| 7C9C | LDY #&ff ; Y = &FF: scan the one key, not wait | ||||||||||||
| 7C9E | JSR osbyte ; Scan it: X = Y = &FF if the key is held. Test whether the key with negative INKEY number X is pressed | ||||||||||||
| 7CA1 | CPY #&ff ; Held only if both Y and X come back &FF | ||||||||||||
| 7CA3 | BNE key_not_pressed ; Y not &FF: the key is up | ||||||||||||
| 7CA5 | CPX #&ff ; X = &FF too? | ||||||||||||
| 7CA7 | BNE key_not_pressed ; No: the key is up | ||||||||||||
| 7CA9 | PLA ; Held: the caller's X back from the stack... | ||||||||||||
| 7CAA | TAX ; ...the hero number again | ||||||||||||
| 7CAB | LDA #0 ; A = 0, Z set: the key is held | ||||||||||||
| 7CAD | RTS ; Return with Z set: the key is held | ||||||||||||
| 7CAE | .key_not_pressed←2← 7CA3 BNE← 7CA7 BNE | ||||||||||||
| PLA ; Up: the caller's X back from the stack... | |||||||||||||
| 7CAF | TAX ; ...the hero number again | ||||||||||||
| 7CB0 | LDA #1 ; A = 1, Z clear: the key is up | ||||||||||||
| 7CB2 | RTS ; Return with Z clear: the key is up | ||||||||||||
| ; The monster comes back facing up on the next trapdoor in turn, ; with the hit points the kill gave it back. It is not drawn ; until next frame. The creature test that follows reads cell_x ; and cell_y, which still hold the dying monster's position ; within its view, as the erase's plot_at_cell left them, not ; the trapdoor's cell. So a creature already on the trapdoor ; does not stop the monster emerging; one that happens to stand ; at the unrelated cell the leftovers name parks the monster at ; &FF,&FF, still alive, where nothing returns it to a trapdoor ; (and a hero there is hurt). | |||||||||||||
| 7CB3 | .monster_reappears←1← 7B3C JMP | ||||||||||||
| INC next_trapdoor ; Each reappearance uses the next trapdoor in turn | |||||||||||||
| 7CB6 | LDA next_trapdoor ; Which trapdoor now? | ||||||||||||
| 7CB9 | CMP #8 ; Past the eighth (7)? | ||||||||||||
| 7CBB | BNE emerge_at_trapdoor ; No: emerge there | ||||||||||||
| 7CBD | LDA #0 ; Yes: wrap round to trapdoor 0... | ||||||||||||
| 7CBF | STA next_trapdoor ; ...for this monster and the next | ||||||||||||
| 7CC2 | .emerge_at_trapdoor←1← 7CBB BNE | ||||||||||||
| LDY next_trapdoor ; Y = the trapdoor to emerge from | |||||||||||||
| 7CC5 | LDA trapdoor_x,y ; Put the monster on it, facing up, with no step | ||||||||||||
| 7CC8 | STA monster_x,x ; ...the trapdoor's x as the monster's | ||||||||||||
| 7CCB | LDA trapdoor_y,y ; The trapdoor's y... | ||||||||||||
| 7CCE | STA monster_y,x ; ...as the monster's | ||||||||||||
| 7CD1 | LDA #spr_monster_up_0 ; Facing up (sprite 9)... | ||||||||||||
| 7CD3 | STA monster_sprite,x ; ...ends the death: alive again, drawn next frame | ||||||||||||
| 7CD6 | LDA #0 ; No step under way: | ||||||||||||
| 7CD8 | STA monster_step,x ; ...step count 0 | ||||||||||||
| 7CDB | STA monster_offset_x,x ; ...no horizontal offset | ||||||||||||
| 7CDE | STA monster_offset_y,x ; ...no vertical offset | ||||||||||||
| 7CE1 | TXA ; Test for a creature at cell_x, cell_y... | ||||||||||||
| 7CE2 | PHA ; ...stacking the number for monster_done | ||||||||||||
| 7CE3 | STX scratch ; Non-zero scratch: skip this monster, check heroes | ||||||||||||
| 7CE6 | JSR find_creature ; cell_x/y: plot_at_cell's leftovers, not the trapdoor | ||||||||||||
| 7CE9 | CMP #0 ; A = 0 if nothing is at that cell | ||||||||||||
| 7CEB | BEQ emerge_done ; Nothing there: the monster stays on the trapdoor | ||||||||||||
| 7CED | PLA ; Something there: park it off the map, still alive | ||||||||||||
| 7CEE | PHA ; ...keeping it stacked for monster_done | ||||||||||||
| 7CEF | TAX ; ...its number in X, which find_creature changed | ||||||||||||
| 7CF0 | LDA #off_map ; Off the map... | ||||||||||||
| 7CF2 | STA monster_x,x ; ...as its x | ||||||||||||
| 7CF5 | STA monster_y,x ; ...and its y: no trapdoor will take it back | ||||||||||||
| 7CF8 | JMP monster_done ; Pull the monster number and on to the next | ||||||||||||
| 7CFB | .emerge_done←1← 7CEB BEQ | ||||||||||||
| JMP monster_done ; Pull the monster number and on to the next | |||||||||||||
| 7CFE | EQUB &00 ; Not referenced | ||||||||||||
| ; Hit points a monster starts with on this level: 6 + 2 x the ; level number (8 on level 1). | |||||||||||||
| 7CFF | .monster_start_hit_points←3← 0E1B STA← 158F LDA← 759B LDA | ||||||||||||
| EQUB &08 | |||||||||||||
Workspace templateThe starting contents of page &0D, the heroes' and missiles' workspace, which reset_workspace copies there whole at the start of every level. Byte +n becomes &0D00 + n. It sets the heroes in the four cells of the start, facing four ways and not stepping; every missile slot empty; each hero's direction and fire keys (hero_key_up etc. at +&70, as negative INKEY numbers for test_key); health digits 9 and 9 + 1 (+&90, +&95), which read 99 once draw_status_panel has taken a point; every view on the start room (+&A0); the heroes' and missiles' sprite bases (+&B0, +&B5); the bit masks test_wall and test_object_free use (+&C0); and the panel rows (+&D0). The bytes between variables are copied with the rest. |
|
| ; Initial contents of page &0D, copied there at the start of ; every level. | |
| 7D00 | .workspace_template←1Used as index base by← 14A2 LDA |
| EQUB &00 ; scratch: working byte | |
| 7D01 | EQUB &00 ; scratch2: working byte |
| 7D02 | EQUB &1F ; cell_x: set before use |
| 7D03 | EQUB &1F ; cell_y: set before use |
| 7D04 | EQUB &D2 ; cell_room: set before use |
| 7D05 | EQUB &D2 ; Copied to &0D05: no variable starts here |
| 7D06 | EQUB &CC ; previous_x: set before use |
| 7D07 | EQUB &B1 ; previous_y: set before use |
| 7D08 | EQUB &07 ; previous_offset_x: set before use |
| 7D09 | EQUB &07 ; previous_offset_y: set before use |
| 7D0A | EQUB &01, &01, &00, ; Copied to &0D0A: no variable starts &2C, &34, &3C ; here |
| 7D10 | EQUB &0B, &0B, ; hero_x: the heroes start at x 11, 11, 12, &0C, &0C ; 12... |
| 7D14 | EQUB &2F ; Copied to &0D14: no variable starts here |
| 7D15 | EQUB &0B, &0C, ; hero_y: ...and y 11, 12, 11, 12, the four &0B, &0C ; cells of the start |
| 7D19 | EQUB &26 ; Copied to &0D19: no variable starts here |
| 7D1A | EQUB &01, &03, ; hero_direction: facing up, right, down and &05, &07 ; left |
| 7D1E | EQUB &2D, &2F ; Copied to &0D1E: no variable starts here |
| 7D20 | EQUB &01, &01, &01, ; hero_frame: walking frame 1 for every &01 ; hero |
| 7D24 | EQUB &5D ; Copied to &0D24: no variable starts here |
| 7D25 | EQUB &00, &00, &00, &00 ; hero_step: not stepping |
| 7D29 | EQUB &16 ; Copied to &0D29: no variable starts here |
| 7D2A | EQUB &00, &00, &00, &00 ; hero_offset_x: no offset |
| 7D2E | EQUB &1D, &1F ; Copied to &0D2E: no variable starts here |
| 7D30 | EQUB &00, &00, &00, &00 ; hero_offset_y: no offset |
| 7D34 | EQUB &03, &05, &07, &05, &07, &36, &35, &37, &3C, &3E, &3D, &3F ; Copied to &0D34: no variable starts here |
| 7D40 | EQUB &01, &82, &81, &83, &88, &8A, &89, &8B, &84, &86, &85, &87 ; missile_x: unused while the slots are empty |
| 7D4C | EQUB &8C, &8E, &8D, &8F, &08, &48, &8A, &48, &98, &48, &AE, &FF ; missile_y: unused while the slots are empty |
| 7D58 | EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 ; missile_direction: every slot empty |
| 7D64 | EQUB &15, &85, &7A, &8A, &48, &20, &00, &09, &68, &AA, &BD, &08 ; missile_sprite_base: set when a missile is fired |
| 7D70 | EQUB &BF, &86, ; hero_key_up: heroes 0-3, read through &B9, &AC ; test_key |
| 7D74 | EQUB &AF, &C6, ; hero_key_down: likewise, one per hero &99, &9B |
| 7D78 | EQUB &9E, &96, &97, &DA ; hero_key_right: likewise |
| 7D7C | EQUB &FF, &A6, &98, &CA ; hero_key_left: likewise |
| 7D80 | EQUB &9F, &D6, &9D, &C9 ; hero_key_fire: likewise |
| 7D84 | EQUB &0D, &C9, &05, &D0, &09, &18, &BD, &04, &0D, &69, &03, &9D ; Copied to &0D84: no variable starts here |
| 7D90 | EQUB spr_digit_9, ; hero_health_tens: the 9 digit sprite... spr_digit_9, spr_digit_9, spr_digit_9 |
| 7D94 | EQUB &D0 ; Copied to &0D94: no variable starts here |
| 7D95 | EQUB spr_digit_9 + 1, ; hero_health_units: ...9 + 1: health spr_digit_9 + 1, ; 99 once a point is taken spr_digit_9 + 1, spr_digit_9 + 1 |
| 7D99 | EQUB &18, &BD, &08, &0D, ; Copied to &0D99: no variable &6D, &40, &0D ; starts here |
| 7DA0 | EQUB <(room_walls + &28), ; view_room: every view starts on >(room_walls + &28), ; the heroes' room, &0C28 <(room_walls + &28), >(room_walls + &28), <(room_walls + &28), >(room_walls + &28), <(room_walls + &28), >(room_walls + &28) |
| 7DA8 | EQUB &00, &00, &BD, &04, ; Copied to &0DA8: no variable &0D, &85, &71, &8A ; starts here |
| 7DB0 | EQUB spr_arrow_up - 1, ; hero_missile_sprites: arrows, spr_fireball_up - 1, ; fireballs, axes, swords spr_axe_up - 1, spr_sword_up - 1 |
| 7DB4 | EQUB &68 ; Copied to &0DB4: no variable starts here |
| 7DB5 | EQUB spr_ranger_up_0 - 1, ; hero_sprites: Ranger, spr_magic_user_up_0 - 1, ; Magic-User, Barbarian, spr_barbarian_up_0 - 1, ; Fighter spr_fighter_up_0 - 1 |
| 7DB9 | EQUB &00, &0D, ; Copied to &0DB9: no variable starts here &D9 |
| 7DBC | EQUB &00, &00, &00, &00 ; hero_has_boots: none |
| 7DC0 | EQUB &80, &40, &20, &10, &08, &04, ; bit_masks: &80 down to &02, &01 ; &01 |
| 7DC8 | EQUB &B9, &30, &0D, &9D, ; Copied to &0DC8: no variable &08, &0D, &4C, &D4 ; starts here |
| 7DD0 | EQUB &18, &46, ; hero_panel_y: the four sections of the &74, &A2 ; status panel |
| 7DD4 | EQUB &E8, &E0, &04, &D0, &0A, &A2, &00, &AD, ; Copied to &40, &0D, &49, &01, &8D, &40, &0D, &8E, ; &0DD4: no &FF, &0D, &68, &A8, &68, &AA, &68, &28, ; variable &60, &DE, &DD, &DF, &F0, &F2, &F1, &F3, ; starts here &F8, &FA, &F9, &FB, &F4, &F6, &F5, &F7, &FC |
| 7DFD | EQUB &1E ; teleport_last: object &1E, the last |
| 7DFE | EQUB &FD ; Copied to &0DFE: no variable starts here |
| 7DFF | EQUB &00 ; victory_sprite_copy: set before use |
| ; Map x of each monster (entries 1-30; entry 0 unused, and ; entries 31-40 spare, of which open_door uses entry 35). During ; a step it stays the cell the monster is leaving until the step ; ends, so find_creature, the missiles and the magic all meet ; the monster there. &FF (off_map) after reset_monsters, and for ; a monster monster_reappears has parked. Written by ; update_monsters, continue_monster_step and monster_reappears. | |
| 7E00 | .monster_x←17Used as index base by← 158C STA← 7667 LDA← 797E CMP← 79E7 LDA← 7A31 INC← 7A3F DEC← 7A45 LDA← 7A5B STA← 7A98 STA← 7ACE LDA← 7AFB STA← 7B04 LDA← 7B41 LDA← 7C46 INC← 7C54 DEC← 7CC8 STA← 7CF2 STA |
| EQUB &00, &04, &0B, &09, &1D, ; Not read: reset_monsters &08, &01, &06, &07, &0A, ; and the trapdoors set the &01, &0B, &1A, &06, &0B, ; monsters &16 | |
| 7E10 | EQUB &15, &0D, &1B, &14, &1A, &09, &1C, &0F, &1E, &02, &1A, &0B, &1C, &0E, &16, &00 ; ...entries 16-31, not read |
| 7E20 | EQUB &00, &00, &00, &1A, &00, &00, ; ...entries 32-40, not &00, &00, &00 ; read |
| ; Map y of each monster, kept like monster_x (entries 1-30; ; entry 35 holds the cell open_door is erasing a door from). | |
| 7E29 | .monster_y←16Used as index base by← 766D LDA← 7986 CMP← 79F0 LDA← 7A2A DEC← 7A38 INC← 7A4B LDA← 7A61 STA← 7A9E STA← 7ADC LDA← 7B01 STA← 7B0A LDA← 7B47 LDA← 7C3F DEC← 7C4D INC← 7CCE STA← 7CF5 STA |
| EQUB &00, &24, &17, &25, &20, ; Not read: reset_monsters &24, &22, &14, &27, &0D, ; and the trapdoors set the &20, &01, &26, &0A, &01, ; monsters &12 | |
| 7E39 | EQUB &05, &20, &29, &0D, &26, &27, &08, &06, &1A, &14, &03, &1D, &07, &0D, &17, &00 ; ...entries 16-31, not read |
| 7E49 | EQUB &00, &00, &00, &1B, &00, &00, ; ...entries 32-40, not &00, &00, &00 ; read |
| ; Each monster's state as a sprite number: 9, &0B, &0D or &0F ; facing up, right, down or left; &15 (the blank) when just ; killed, then &16-&19, the sparkles of its death, one a frame. ; It reaches &1A only for the moment before monster_reappears ; resets it to 9. | |
| 7E52 | .monster_sprite←19Used as index base by← 1587 STA← 7144 LDA← 7598 STA← 7683 LDA← 768C STA← 7A0D LDA← 7A23 LDA← 7A77 STA← 7A81 INC← 7AB4 STA← 7ABB INC← 7AC3 LDA← 7B11 LDA← 7B32 INC← 7B35 LDA← 7B4D LDA← 7BF0 LDA← 7C38 LDA← 7CD3 STA |
| EQUB &00, &09, &0D, &0B, &0B, &0B, &09, &0F, &0F, &0B, &0D, &0B, &0B, &0F, &0D, &0D, &09, &0F, &0B, &0F, &0B, &0B, &0F, &09, &0D, &0F, &0B, &09, &0D, &0B, &09, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Each monster's animation frame (0 or 1), added to its facing ; sprite; toggled on each frame of a step. Entries 1-30 are ; used. Nothing sets it at the start of a level, so each monster ; starts on whatever frame the table holds. | |
| 7E7B | .monster_frame←3Used as index base by← 7B14 ADC← 7C2B LDA← 7C30 STA |
| EQUB &00, &00, &01, &00, &00, &01, &01, &00, &01, &01, &00, &01, &01, &01, &00, &01, &00, &01, &00, &01, &01, &00, &00, &01, &01, &00, &00, &00, &01, &01, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; How far each monster is drawn across from its cell during a ; step, in byte columns: 0, or +/-1 to 3. | |
| 7EA4 | .monster_offset_x←15Used as index base by← 79FD LDA← 7A69 STA← 7AA6 STA← 7AEF STA← 7B19 LDA← 7B52 LDA← 7BF9 STA← 7C0D STA← 7C17 STA← 7C27 STA← 7C59 STA← 7C5F LDA← 7C66 DEC← 7C6C INC← 7CDB STA |
| EQUB &00, &00, &00, &02, &02, &02, &00, &FD, &FE, &01, &00, &02, &03, &00, &00, &00, &00, &FE, &00, &00, &01, &00, &00, &00, &00, &00, &03, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; How far each monster is drawn down from its cell during a ; step, in pixel rows: 0, or +/-3, 6 or 9. | |
| 7ECD | .monster_offset_y←17Used as index base by← 7A02 LDA← 7A6C STA← 7AA9 STA← 7AF2 STA← 7B1E LDA← 7B57 LDA← 7BFE STA← 7C08 STA← 7C1C STA← 7C22 STA← 7C5C STA← 7C6F LDA← 7C77 LDA← 7C7C STA← 7C83 LDA← 7C88 STA← 7CDE STA |
| EQUB &00, &FD, &00, &00, &00, &00, &FA, &00, &00, &00, &03, &00, &00, &00, &06, &03, &FD, &00, &00, &00, &00, &00, &00, &00, &06, &00, &00, &F7, &00, &00, &F7, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Frames left in each monster's step between cells: 3 when the ; step starts, counted down by continue_monster_step, 0 when the ; monster is not stepping. Not looked at while a monster is ; dying; monster_reappears clears it. | |
| 7EF6 | .monster_step←7Used as index base by← 7A17 LDA← 7A66 STA← 7AA3 STA← 7AEC STA← 7BED STA← 7C33 DEC← 7CD8 STA |
| EQUB &00, &03, &00, &02, &02, &02, &02, &01, &02, &03, &03, &02, &01, &00, &02, &03, &03, &02, &00, &00, &03, &00, &00, &00, &02, &00, &01, &01, &00, &00, &01, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 | |
| ; Map x of each object on the level (entries 1-30), from the ; level file; &FF once collected. Entry 30 is the exit. | |
| 7F20 | .object_x←9Used as index base by← 1515 STA← 7173 LDA← 719A STA← 730D LDA← 7337 LDA← 73EA LDA← 7413 STA← 7469 STA← 74BB STA |
| EQUB &00, &FF, &FF, &FF, &FF, &FF, ; Not read: unpack_level &18, &04, &04, &05, &FF, &FF, ; copies each level's &FF, &FF, &FF, &FF ; objects here | |
| 7F30 | EQUB &FF, &FF, &FF, &FF, &FF, &01, &07, &04, &04, &FF, &FF, &FF, &FF, &FF ; ...entries 16-29, not read |
| ; Map x of the exit (object 30). | |
| 7F3E | .exit_x←4← 1F3B CMP← 1F77 LDA← 1F85 STA← 2029 STA |
| EQUB &04 ; ...the exit's entry | |
| ; Map y of each object. | |
| 7F3F | .object_y←9Used as index base by← 151B STA← 717B LDA← 719D STA← 7313 LDA← 7342 LDA← 73F3 LDA← 7416 STA← 746C STA← 74BE STA |
| EQUB &00, &FF, &FF, &FF, &FF, &FF, ; Not read: unpack_level &15, &18, &19, &19, &FF, &FF, ; copies each level's &FF, &FF, &FF, &FF ; objects here | |
| 7F4F | EQUB &FF, &FF, &FF, &FF, &FF, &2A, &2A, &2B, &2E, &FF, &FF, &FF, &FF, &FF ; ...entries 16-29, not read |
| ; Map y of the exit (object 30). | |
| 7F5D | .exit_y←4← 1F43 CMP← 1F7D LDA← 1F88 STA← 202F STA |
| EQUB &2C ; ...the exit's entry | |
| ; Each object's type, which is also its sprite: &28 treasure, ; &29 food, &2A Cross of Resurrection, &2B teleporter, &51 exit, ; &53-&5E energy drainer (advancing with each hit), &5F Boots of ; Speed, &60 magic helmet, &61 potion of healing, &62 pile of ; weapons, &63 magic sword. | |
| 7F5E | .object_type←7Used as index base by← 1521 STA← 7183 LDA← 718E INC← 7191 LDA← 7319 LDA← 735C LDA← 73C8 LDA |
| EQUB &00, &5F, &5F, &5F, &29, &63, ; Not read: unpack_level &5F, &53, &2B, &53, &28, &28, ; copies each level's &60, &60, &28, &2A ; objects here | |
| 7F6E | EQUB &62, &28, &28, &29, &28, &2B, &2B, &2B, &2B, &29, &28, &28, &29, &28 ; ...entries 16-29, not read |
| 7F7C | EQUB &51 ; ...the exit's entry |
| 7F7D | EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00 ; Not referenced |
WRCHV handler: print letters and digits in the game fontInstalled on WRCHV while the game runs. A letter (either case) or a digit is printed in the game's own font: its eight-byte glyph is copied over the definition of character 128 (user_char_128) and character 128 is printed instead. Every other character is printed unchanged. Both paths finish in the MOS 1.20 OSWRCH routine at mos_oswrch_default, jumped to directly rather than through the WRCHV value saved at start-up. Lower-case letters share the capitals' glyphs. The handler keeps the character in plot_x, the sprite plotter's zero-page column, and it looks at every byte alone, with no notion of a VDU sequence: a VDU parameter byte that falls in '0'-'9', 'A'-'Z' or 'a'-'z' is sent as &80 too, so VDU sequences with such parameters go out with the MOS's own WRCHV: draw_view_frames puts it back around its PLOT commands. VDU 23,0,6,25 in start_level passes unharmed (25 is a control code). The glyph goes to &0C00 because MOS 1.20 keeps character 128's definition there, so room_walls must stay at &0C00 too.
|
|||||||||||||
| 7F8F | .wrch_handler | ||||||||||||
| STA plot_x ; Keep the character in plot_x, borrowed as scratch | |||||||||||||
| 7F91 | TXA ; Save the caller's X... | ||||||||||||
| 7F92 | PHA ; ...on the stack | ||||||||||||
| 7F93 | TYA ; ...and the caller's Y | ||||||||||||
| 7F94 | PHA ; ...on the stack: OSWRCH must preserve both | ||||||||||||
| 7F95 | LDA plot_x ; Classify the character by range | ||||||||||||
| 7F97 | CMP #'0' ; Below '0': a control code, space or punctuation? | ||||||||||||
| 7F99 | BCC pass_character ; Controls, space, punctuation: the MOS font | ||||||||||||
| 7F9B | CMP #':' ; Below ':', so a digit '0'-'9'? | ||||||||||||
| 7F9D | BCC digit_glyph ; A digit: use the game's digit glyph | ||||||||||||
| 7F9F | CMP #'A' ; Below 'A', so ':' to '@'? | ||||||||||||
| 7FA1 | BCC pass_character ; Punctuation: the MOS font | ||||||||||||
| 7FA3 | CMP #'[' ; Below '[', so a capital 'A'-'Z'? | ||||||||||||
| 7FA5 | BCC capital_letter ; A capital: use the game's letter glyph | ||||||||||||
| 7FA7 | CMP #'a' ; Below 'a', so '[' to '`'? | ||||||||||||
| 7FA9 | BCC pass_character ; Punctuation: the MOS font | ||||||||||||
| 7FAB | CMP #'{' ; '{' or above, past the lower-case letters? | ||||||||||||
| 7FAD | BCS pass_character ; '{' and above: the MOS font | ||||||||||||
| 7FAF | SEC ; Lower case: letter number 0-25... | ||||||||||||
| 7FB0 | SBC #'a' ; ...so it is drawn with the capital's glyph | ||||||||||||
| 7FB2 | JMP glyph_offset ; Join the capitals' path | ||||||||||||
| 7FB5 | .capital_letter←1← 7FA5 BCC | ||||||||||||
| SEC ; Capital: letter number 0-25... | |||||||||||||
| 7FB6 | SBC #'A' ; ...0 for 'A' | ||||||||||||
| 7FB8 | .glyph_offset←1← 7FB2 JMP | ||||||||||||
| ASL ; Glyph offset = letter x 8 in font_letters: x 2... | |||||||||||||
| 7FB9 | ASL ; ...x 4 (8 bytes a glyph)... | ||||||||||||
| 7FBA | ASL ; ...x 8: the glyph's offset (at most 200) | ||||||||||||
| 7FBB | BNE copy_glyph ; Branch to the next instruction either way | ||||||||||||
| 7FBD | .copy_glyph←1← 7FBB BNE | ||||||||||||
| TAX ; X indexes the glyph in font_letters | |||||||||||||
| 7FBE | CLC ; End offset = start + 8... | ||||||||||||
| 7FBF | ADC #8 ; ...one glyph's eight rows... | ||||||||||||
| 7FC1 | STA plot_x ; ...in plot_x, the character no longer needed | ||||||||||||
| 7FC3 | LDY #0 ; Y indexes character 128's definition at &0C00 | ||||||||||||
| 7FC5 | .copy_letter_glyph←1← 7FCF BNE | ||||||||||||
| LDA font_letters,x ; Copy a row of the letter's glyph... | |||||||||||||
| 7FC8 | STA room_walls,y ; ...over character 128's definition | ||||||||||||
| 7FCB | INY ; Next row of character 128 | ||||||||||||
| 7FCC | INX ; Next row of the glyph | ||||||||||||
| 7FCD | CPX plot_x ; All eight rows copied? | ||||||||||||
| 7FCF | BNE copy_letter_glyph ; No: copy the next row | ||||||||||||
| 7FD1 | .restore_registers←1← 7FF4 BEQ | ||||||||||||
| PLA ; Restore the caller's Y... | |||||||||||||
| 7FD2 | TAY ; ...from the stack | ||||||||||||
| 7FD3 | PLA ; ...and the caller's X | ||||||||||||
| 7FD4 | TAX ; ...from the stack | ||||||||||||
| 7FD5 | LDA #&80 ; Character 128, which now looks like the glyph... | ||||||||||||
| 7FD7 | JMP mos_oswrch_default ; ...printed by the MOS 1.20 OSWRCH routine itself | ||||||||||||
| 7FDA | .digit_glyph←1← 7F9D BCC | ||||||||||||
| SEC ; Digit: digit number 0-9... | |||||||||||||
| 7FDB | SBC #'0' ; ...0 for '0' | ||||||||||||
| 7FDD | ASL ; Glyph offset = digit x 8 in font_digits: x 2... | ||||||||||||
| 7FDE | ASL ; ...x 4 (8 bytes a glyph)... | ||||||||||||
| 7FDF | ASL ; ...x 8: the glyph's offset | ||||||||||||
| 7FE0 | TAX ; X indexes the glyph in font_digits | ||||||||||||
| 7FE1 | CLC ; End offset = start + 8... | ||||||||||||
| 7FE2 | ADC #8 ; ...one glyph's eight rows... | ||||||||||||
| 7FE4 | STA plot_x ; ...in plot_x, the character no longer needed | ||||||||||||
| 7FE6 | LDY #0 ; Y indexes character 128's definition at &0C00 | ||||||||||||
| 7FE8 | .copy_digit_glyph←1← 7FF2 BNE | ||||||||||||
| LDA font_digits,x ; Copy a row of the digit's glyph... | |||||||||||||
| 7FEB | STA room_walls,y ; ...over character 128's definition | ||||||||||||
| 7FEE | INY ; Next row of character 128 | ||||||||||||
| 7FEF | INX ; Next row of the glyph | ||||||||||||
| 7FF0 | CPX plot_x ; All eight rows copied? | ||||||||||||
| 7FF2 | BNE copy_digit_glyph ; No: copy the next row | ||||||||||||
| 7FF4 | BEQ restore_registers ; Done (always taken): print character 128 | ||||||||||||
| 7FF6 | .pass_character←4← 7F99 BCC← 7FA1 BCC← 7FA9 BCC← 7FAD BCS | ||||||||||||
| PLA ; Not a letter or digit: restore the caller's Y... | |||||||||||||
| 7FF7 | TAY ; ...from the stack | ||||||||||||
| 7FF8 | PLA ; ...and the caller's X | ||||||||||||
| 7FF9 | TAX ; ...from the stack | ||||||||||||
| 7FFA | LDA plot_x ; The character, unchanged, from plot_x... | ||||||||||||
| 7FFC | JMP mos_oswrch_default ; ...printed by the MOS 1.20 OSWRCH routine itself | ||||||||||||
| 7FFF | EQUB &00 ; Not referenced | ||||||||||||
