Dunjunz: title screen and loader

Dunjunz, official flippy disc (Bug-Byte, 1987), Model B side

Updated 8 Nov 2026

← All Dunjunz versions

FileLoadExecLengthSHA-256
Dunjunz&26C0&2700&089Ca1b8f4a91f0eb3f4a375eeb3f8ba17785ba5b0a2016637580bb899eec87c9570

Load the title screen while output is off

*DUNJUNZ is the Model B side's loader and title screen. It is run at title_start (&2700), whose banner describes the whole run: set up page &08 for Coder and the game, show the title picture with its twinkling stars until a key is pressed, then select the game's display and run Coder, which never returns. This first routine is one of its steps. Load the title picture, SCREEN, straight into MODE 2 screen memory at &3280 with VDU output disabled, then enable output again. Called once, by title_start, after it has selected MODE 2 and made all sixteen colours black, so the picture arrives unseen and appears all at once when title_start restores the colours. VDU 21 keeps any filing system message off the picture.

On ExitAcorrupted
Xcorrupted
Ycorrupted
26C0 .load_title_screen←1← 2763 JSR
LDA #&15 ; VDU 21: disable VDU output
26C2 JSR oswrch ; ...so the load prints nothing over the picture
26C5 LDX #<(load_screen_command) ; *LOAD SCREEN: the title picture...
26C7 LDY #>(load_screen_command) ; ...(X, Y) = the command line
26C9 JSR oscli ; ...straight into screen memory at &3280
26CC LDA #6 ; VDU 6: enable VDU output
26CE JSR oswrch ; ...so the VDU calls that follow take effect
26D1 RTS ; Return with the picture in place, still unseen

Disable VDU output and run Coder

The hand-over to Coder: VDU 21, then *CODER, which loads the level loader at &5000 and runs it; it does not return. Called last by title_start, once the game's display is selected and the BREAK intercept is armed. Coder starts with VDU output disabled, so no filing system message reaches the screen, and enables it again with VDU 6.

26D2 .leave_title←1← 2791 JSR
LDA #&15 ; VDU 21: disable VDU output
26D4 JSR oswrch ; ...so loading Coder prints nothing on the game screen
26D7 LDX #<(coder_command) ; *CODER: load and run the level loader
26D9 LDY #>(coder_command) ; ...(X, Y) = the command line
26DB JSR oscli ; ...never returns: Coder takes over the machine
fall through ↓

Unused

Leftover bytes.

26DE EQUB &0D, &36, &17, &00, &0D, &1E, &00, &2A, &05, &14, &00, &15, &00, &00, &00, &00, &2A, &00, &00, &04, &08, &00, &2A, &04, &08, &2A, &15, &3C, &3D, &00, &33, &3C, &39, &00 ; Not used

Set up, show the title and run Coder

The entry point of *DUNJUNZ (load &26C0, run at &2700), the loader and title screen. It is run when the disc is turned over to this side (the other side's BOOT asks for that and SPACE), and again after every game over, by the game's restart intercept (*DISC, *DUNJUNZ) during the reset that ends the game. The run is a straight line in four phases, marked by block comments below. Set-up: disable ESCAPE and make the cursor keys return codes. Page &08, which the reset between levels leaves alone: levels_started = 0 and level_digits = "0 ", which Coder advances to 1 and "1 " before loading Level1; for each hero, hero_score_ten_thousands = &69 (no digit) and hero_absent = 0 (playing), so every game starts with all four heroes switched on in the menu. The BREAK intercept's address is set to &15B5 and left disabled. Title: select MODE 2 (*TV 255,1) with all sixteen colours black, load SCREEN unseen, restore the colours, and twinkle_stars until a key other than SHIFT or CTRL is pressed. Hand-over: select the game's display (*TV 252,1, MODE 2, cursor off), *DISC, arm the BREAK intercept as JMP &15B5, and leave_title disables VDU output and runs *CODER, which never returns. Coder starts with ESCAPE disabled, VDU output disabled, the page &08 values above and the intercept armed. Coder cancels the intercept among its first instructions, so it is armed only while *CODER loads. A BREAK in that time jumps to &15B5, which holds the game's next_level_intercept only if the game has already been played since power-on, as after a game over.

On ExitAcorrupted
Xcorrupted
Ycorrupted
2700 .title_start
LDA #osbyte_escape_break_effect ; OSBYTE &C8: ESCAPE disabled...
2702 LDX #1 ; ...X = 1: ESCAPE disabled, BREAK as normal...
2704 LDY #0 ; ...Y = 0: X replaces the old setting
2706 JSR osbyte ; ...so the ESCAPE key cannot stop the program osbyte: escape break effect
2709 LDA #osbyte_set_cursor_editing ; OSBYTE 4, 1: no cursor editing...
270B LDX #1 ; ...X = 1: the arrow keys and COPY give codes
270D JSR osbyte ; ...instead of moving an editing cursor Set cursor editing keys
; Page &08 values for Coder and the game: the level counter and ; filename digits Coder advances, and each hero's score digit ; and menu switch.
2710 LDA #0 ; Levels started = 0, for Coder
2712 STA levels_started ; ...in page &08, which survives a reset
2715 LDA #'0' ; Level digits = "0 "...
2717 STA level_digits ; ...first digit '0'...
271A LDA #' ' ; ...second digit a space
271C STA level_digits + 1 ; ...for the level filename
271F LDX #3 ; For each hero...
2721 .init_hero_tables←1← 272C BPL
LDA #spr_no_small_digit ; ...no ten-thousands digit (sprite &69)...
2723 STA hero_score_ten_thousands,x ; ...in the score digit table at &08B0...
2726 LDA #0 ; ...and switched on...
2728 STA hero_absent,x ; ...at &08B4 (the menu tables)
272B DEX ; Next hero, counting 3 down to 0
272C BPL init_hero_tables ; Until all four heroes are set
; Point the BREAK intercept at the game's next-level code, but ; leave it disabled until Coder is about to run.
272E LDA #<(game_next_level_intercept) ; BREAK intercept address = &15B5 (the game's next-level intercept)...
2730 STA os_break_intercept + 1 ; ...as the JMP's address, low byte
2733 LDA #>(game_next_level_intercept) ; ...then its page, &15...
2735 STA os_break_intercept + 2 ; ...completing the JMP's address
2738 LDA #0 ; ...disabled for now: &0287 is not a JMP
273A STA os_break_intercept ; ...so a BREAK now does not run the game's code
; Title: select MODE 2 with every colour black, load the ; picture, restore the colours, then twinkle stars on it until a ; key is pressed.
273D LDX #<(tv_title_command) ; *TV 255,1: vertical shift -1 line, interlace off
273F LDY #>(tv_title_command) ; ...(X, Y) = the command line
2741 JSR oscli ; ...taking effect at the MODE change below
2744 JSR mode2_cursor_off ; MODE 2, cursor off, for the title picture
2747 LDX #&0f ; Make all sixteen colours black, hiding the load...
2749 .black_colours←1← 2761 BPL
LDA #&13 ; ...VDU 19, colour, 0, 0, 0, 0...
274B JSR oswrch ; ...VDU 19: redefine a logical colour...
274E TXA ; ...logical colour X...
274F JSR oswrch ; ...the colour being redefined
2752 LDA #0 ; ...zero for the four remaining bytes
2754 JSR oswrch ; ...physical colour 0: black
2757 JSR oswrch ; ...then the three bytes VDU 19 also takes
275A JSR oswrch ; ...second of the three
275D JSR oswrch ; ...third of the three
2760 DEX ; Next logical colour
2761 BPL black_colours ; Until colours 15 to 0 are all black
2763 JSR load_title_screen ; Load the title picture, unseen in black
2766 NOP ; Padding: four NOPs that do nothing
2767 NOP ; ...the second of the four
2768 NOP ; ...the third of the four
2769 NOP ; ...the last of the four
276A LDA #&14 ; VDU 20: default colours, showing the picture
276C JSR oswrch ; ...so the loaded picture appears all at once
276F LDA #0 ; Plot the stars left to right
2771 STA title_plot_reversed ; ...so title_plot_star steps right across a row
2773 LDA #osbyte_flush_buffer ; OSBYTE &15: flush the buffer X
2775 JSR osbyte ; ...X is whatever OSCLI left: buffer unknown Flush specific buffer X
2778 JSR twinkle_stars ; Twinkle stars until a key is pressed
; Hand-over: a key was pressed, so select the game's display and ; DFS, arm the BREAK intercept and run Coder.
277B LDX #<(tv_game_command) ; *TV 252,1: vertical shift -4 lines, interlace off
277D LDY #>(tv_game_command) ; ...(X, Y) = the command line
277F JSR oscli ; ...taking effect at the MODE change below
2782 JSR mode2_cursor_off ; MODE 2, cursor off: clears the title from the screen
2785 LDX #<(disc_command) ; *DISC: select DFS...
2787 LDY #>(disc_command) ; ...(X, Y) = the command line
2789 JSR oscli ; ...so *CODER is looked for on the disc
278C LDA #opcode_jmp ; Arm the BREAK intercept: &0287 = JMP, so a BREAK...
278E STA os_break_intercept ; ...now runs the game's next-level code at &15B5
2791 JSR leave_title ; Disable output and run Coder (no return)
2794 EQUB &EA ; Padding
2795 EQUB &EA ; ...never run: leave_title does not return
2796 EQUB &EA ; ...never run
2797 EQUB &EA ; ...never run
; The OSCLI command lines, each ended by a carriage return.
2798 .load_screen_command
EQUS "LOAD SCREEN", &0D ; The title picture, for load_title_screen
27A4 .disc_command
EQUS "DISC", &0D ; Select DFS, before *CODER
27A9 .coder_command
EQUS "CODER", &0D ; Run the level loader
27AF .tv_game_command
EQUS "TV252 1", &0D ; Vertical shift -4, interlace off: the game
27B7 .tv_title_command
EQUS "TV255 1", &0D ; Vertical shift -1, interlace off: the title
fall through ↓

Select MODE 2 and turn the cursor off

VDU 22,2 then VDU 23,0,10,&20,0,0,0,0,0,0 (6845 register 10: no cursor), from cursor_off_vdu. Called twice by title_start, each time just after a *TV, whose vertical shift the mode change brings into effect: once for the title picture and once for the game's display. Both times it clears the screen.

On ExitAcorrupted
Xcorrupted
Ypreserved
27BF .mode2_cursor_off←2← 2744 JSR← 2782 JSR
LDA #&16 ; VDU 22, 2: MODE 2
27C1 JSR oswrch ; ...selects a mode, clearing the screen...
27C4 LDA #2 ; ...mode 2: 16 colours, 20 columns
27C6 JSR oswrch ; ...sent as the mode number
27C9 LDX #0 ; Send VDU 23,0,10,&20,...: cursor off
27CB .send_cursor_off_vdu←1← 27D4 BNE
LDA cursor_off_vdu,x ; Next byte of cursor_off_vdu...
27CE JSR oswrch ; ...to the VDU drivers
27D1 INX ; ...on to the next
27D2 CPX #&0b ; ...until all eleven are sent
27D4 BNE send_cursor_off_vdu ; Not yet: send the next
27D6 RTS ; Return with MODE 2 clear and no cursor

Unused

Leftover bytes.

27D7 EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00, &00, &00, &0A, &00 ; Not used
; VDU 23,0,10,&20,0,0,0,0,0,0, sent byte by byte by ; mode2_cursor_off: &20 to 6845 register 10, the cursor start ; line, whose bits 5-6 = 01 turn the cursor off.
27F0 .cursor_off_vdu←1Used as index base by← 27CB LDA
EQUB &17, &00, &0A, &20, &00, ; VDU &00, &00, &00, &00, &00, ; 23,0,10,&20,0,0,0,0,0,0: &00 ; cursor off
27FB EQUB &00, &00, &05, &07, &00 ; Not used

Plot a star frame on the title screen

Exclusive-OR one frame of the star animation, 7 bytes (14 pixels) by 28 pixel rows, onto the MODE 2 title screen with its top left at byte column plot_x and pixel row plot_y. Because it is an exclusive-OR, plotting the same frame twice erases it and restores the picture beneath, which is how advance_stars and twinkle_stars remove a star. Called only through plot_star. The method is the game's plot_sprite, with the frame fixed at 7 by 28: title_screen_address gives the top left; each row steps 8 bytes (one character cell) per byte across, right or, if title_plot_reversed is non-zero, left; the next row starts one byte below the last row's start, and every eighth row &278 (640 - 8) further on, into the next character row. title_start sets title_plot_reversed to 0, so the stars are always plotted left to right. Leaves sprite_data_ptr just past the frame and screen_ptr below it.

On EntryPLOT_Xbyte column
PLOT_Ypixel row
SPRITE_NUMBERframe, 0-6
2800 .title_plot_star←1← 29CA JSR
LDA #7 ; Every star frame is seven bytes wide...
2802 STA sprite_width ; ...(14 MODE 2 pixels)...
2804 LDA #&1c ; ...and 28 pixel rows high...
2806 STA sprite_height ; ...three and a half character rows
2808 LDX sprite_number ; Point at the frame's data...
280A LDA star_frames_lo,x ; ...low byte from star_frames_lo
280D STA sprite_data_ptr ; ...for the byte loop below
280F LDA star_frames_hi,x ; ...high byte from star_frames_hi
2812 STA sprite_data_ptr_hi ; ...the frames run on from &2A00
2814 JSR title_screen_address ; Screen address of the star's top left
2817 LDX sprite_height ; For each pixel row of the frame...
2819 .plot_star_row←1← 2873 BNE
LDA screen_ptr ; ...remember where the row starts...
281B STA row_start_ptr ; ...to step down one pixel row from later
281D LDA screen_ptr_hi ; ...and the page of the row's start...
281F STA row_start_ptr_hi ; ...into row_start_ptr_hi
2821 TXA ; ...and keep the row count...
2822 PHA ; ...on the stack while X counts bytes
2823 LDX sprite_width ; ...for each byte across...
2825 .plot_star_byte←1← 284E BNE
LDA (sprite_data_ptr),y ; ...exclusive-OR the frame onto the screen...
2827 EOR (screen_ptr),y ; ...flip the screen pixels the frame sets...
2829 STA (screen_ptr),y ; ...so plotting twice erases the star
282B LDA title_plot_reversed ; ...and step a character cell (8 bytes) right or left
282D BNE plot_star_left ; Non-zero: step left instead
282F CLC ; Step right: screen_ptr + 8...
2830 LDA screen_ptr ; ...screen pointer low byte...
2832 ADC #8 ; ...plus 8: the next cell to the right
2834 STA screen_ptr ; ...where the next frame byte goes
2836 BCC plot_star_next_data ; No carry: pointer done
2838 INC screen_ptr_hi ; Carry into the high byte
283A BNE plot_star_next_data ; ...always taken: screen pages are never 0
283C .plot_star_left←1← 282D BNE
SEC ; Step left: screen_ptr - 8...
283D LDA screen_ptr ; ...screen pointer low byte...
283F SBC #8 ; ...minus 8: the next cell to the left
2841 STA screen_ptr ; ...where the next frame byte goes
2843 BCS plot_star_next_data ; No borrow: pointer done
2845 DEC screen_ptr_hi ; Borrow from the high byte
2847 .plot_star_next_data←3← 2836 BCC← 283A BNE← 2843 BCS
INC sprite_data_ptr ; Next byte of the frame
2849 BNE plot_star_next_byte ; No carry: pointer done
284B INC sprite_data_ptr_hi ; Carry into the high byte
284D .plot_star_next_byte←1← 2849 BNE
DEX ; Next byte across
284E BNE plot_star_byte ; More bytes in this row: plot the next
2850 CLC ; Down one pixel row from the row's start...
2851 LDA row_start_ptr ; ...from the row's start, low byte...
2853 ADC #1 ; ...plus one: the next byte in the cell
2855 STA screen_ptr ; ...is the next row's first byte
2857 LDA row_start_ptr_hi ; ...the row start's page...
2859 ADC #0 ; ...with the carry
285B STA screen_ptr_hi ; ...completing the next row's address
285D LDA screen_ptr ; ...crossing into the next character row every eight (640 - 8 bytes on)
285F AND #7 ; ...pixel row within the character row
2861 BNE plot_star_next_row ; Not 0: still in the same character row
2863 CLC ; Row 0: moved into the next character row...
2864 LDA screen_ptr ; ...so add 640 - 8 to the pointer...
2866 ADC #&78 ; ...low byte of &278...
2868 STA screen_ptr ; ...the top of the cell below
286A LDA screen_ptr_hi ; ...and screen_ptr's page...
286C ADC #2 ; ...plus &02 with the carry
286E STA screen_ptr_hi ; ...completing the address in the next character row
2870 .plot_star_next_row←1← 2861 BNE
PLA ; Recover the row count...
2871 TAX ; ...back into X as the rows left...
2872 DEX ; ...one row fewer to go
2873 BNE plot_star_row ; More rows: plot the next
2875 RTS ; Return with the frame flipped onto the screen

Calculate a title screen address

The MODE 2 screen address of byte column plot_x and pixel row plot_y: &3000 + the character row's offset (plot_y DIV 8, x 640) + plot_y MOD 8 + 8 x plot_x. The row offsets are read from MOS 1.20's table at &C375, so this loader relies on that ROM. It is a copy of the game's screen_address. Called only by title_plot_star, for a star's top left.

On EntryPLOT_Xbyte column
PLOT_Ypixel row
On ExitSCREEN_PTRscreen address
Y0
2876 .title_screen_address←1← 2814 JSR
LDA plot_y ; Character row x 2...
2878 LSR ; ...divide plot_y by 4...
2879 LSR ; ...(character row x 2)...
287A AND #&fe ; ...even, to index the table's byte pairs
287C TAY ; ...as Y, indexing the row offset table
287D LDA mos_row_offsets,y ; High byte of row x 640, from the MOS table...
2880 CLC ; ...plus &3000, the screen start
2881 ADC #>(screen_start) ; ...the screen starts at &3000
2883 STA screen_ptr_hi ; ...as the high byte
2885 LDA mos_row_offsets + 1,y ; Low byte of row x 640
2888 STA screen_ptr ; ...as the low byte
288A LDA plot_y ; Plus the pixel row within the character row
288C AND #7 ; ...plot_y MOD 8...
288E ADC screen_ptr ; ...added to the low byte (no carry out)
2890 STA screen_ptr ; ...the row's byte within each cell
2892 CLC ; Plus 8 x byte column: high part...
2893 LDA plot_x ; ...plot_x DIV 32, the page share of 8 x plot_x...
2895 AND #&e0 ; ...top three bits, worth &100 each x 8...
2897 ROL ; ...rotated through carry four times...
2898 ROL ; ...towards the bottom...
2899 ROL ; ...of the byte...
289A ROL ; ...as bits 2-0: the high byte's share
289B CLC ; ...to add to the high byte...
289C ADC screen_ptr_hi ; ...plus the row's page...
289E STA screen_ptr_hi ; ...in the screen pointer
28A0 LDA plot_x ; ...then the low byte of 8 x plot_x...
28A2 ASL ; ...plot_x x 2...
28A3 ASL ; ...plot_x x 4...
28A4 ASL ; ...x 8: eight bytes per character cell
28A5 CLC ; ...to add to the low byte...
28A6 ADC screen_ptr ; ...plus the row's low byte...
28A8 STA screen_ptr ; ...in the screen pointer
28AA BCC title_screen_address_done ; No carry: address done
28AC INC screen_ptr_hi ; Carry into the high byte
28AE .title_screen_address_done←1← 28AA BCC
LDY #0 ; Y = 0 for the plotter's (ptr),Y accesses
28B0 RTS ; Return with screen_ptr set and Y = 0

Unused

Leftover bytes.

28B1 EQUB &0D, &18, &A5, &74, &69, &78, &85, &74, &A5, &75, &69, &02, &85, &75, &68 ; Not used
; Low bytes of the seven star frames' addresses (&2A00 + &C4 x ; frame), indexed by frame 0-6 and read by title_plot_star.
28C0 .star_frames_lo←1Used as index base by← 280A LDA
EQUB <(star_frame_data), ; Frames 0-6, low bytes <(star_frame_data + &c4), <(star_frame_data + &0188), <(star_frame_data + &024c), <(star_frame_data + &0310), <(star_frame_data + &03d4), <(star_frame_data + &0498)
28C7 EQUB &15, &4A, &29, &FE, &A8, &B9, &75, &C3, &18 ; Not used
; High bytes of the seven star frames' addresses, indexed by ; frame 0-6 and read by title_plot_star.
28D0 .star_frames_hi←1Used as index base by← 280F LDA
EQUB >(star_frame_data), ; Frames 0-6, high bytes >(star_frame_data + &c4), >(star_frame_data + &0188), >(star_frame_data + &024c), >(star_frame_data + &0310), >(star_frame_data + &03d4), >(star_frame_data + &0498)
28D7 EQUB &22, &74, &A5, &71, &29, &07, &65, &74, &85, &2A, &2A, &2B, &2C, &2D, &2D, &2E, &22, &2A, &2A, &18, &65, &75, &85, &75, &A5, &70, &0A, &0A, &0A, &18, &65, &74, &85, &74, &90, &02, &E6, &75, &A0, &00, &00 ; Not used

Twinkle stars on the title screen until a key is pressed

The title screen's wait for a key. Called once by title_start, after the picture is shown. Up to three stars twinkle at once, each at one of the eight places in star_places_x and star_places_y, picked at random. A star grows through frames 0-6 and shrinks back through 5-0, then disappears and frees its place. Each pass of the loop: when the low two bits of the System VIA's timer 1 are 0 (about one pass in four), start_star starts a star if one is free; advance_stars moves every star on a frame and pauses, which sets the pace; then OSBYTE &7A scans the keyboard from key 16, so SHIFT and CTRL alone do not end the title. When a key is pressed the stars still showing are erased, though the MODE change that title_start makes next clears the screen anyway.

On ExitAcorrupted
Xcorrupted
Ycorrupted
2900 .twinkle_stars←1← 2778 JSR
LDX #2 ; No stars showing
2902 LDA #0 ; ...0 for every star
2904 .clear_star_showing←1← 2908 BPL
STA star_showing,x ; ...in star X's star_showing flag...
2907 DEX ; ...then the star below
2908 BPL clear_star_showing ; Until stars 2 to 0 are cleared
290A .twinkle_loop←1← 291E BEQ
LDA system_via_t1c_l ; One time in four (System VIA timer 1, low bits)...
290D AND #3 ; ...lowest two bits, 0-3...
290F BNE twinkle_advance ; Not 0: no new star this time
2911 JSR start_star ; ...start a star, if one of the three is free
2914 .twinkle_advance←1← 290F BNE
JSR advance_stars ; Grow or shrink every star a frame, then pause
2917 LDA #osbyte_scan_keyboard_from_16 ; OSBYTE &7A: any key other than SHIFT or CTRL?
2919 JSR osbyte ; ...X = the key number, &FF if none Scan keyboard from key 16
291C CPX #&ff ; ...&FF: no key held down?
291E BEQ twinkle_loop ; No key: keep twinkling
2920 LDY #2 ; Yes: erase the stars still showing...
2922 .erase_stars←1← 292B BPL
LDA star_showing,y ; ...star Y showing?
2925 BEQ erase_next_star ; No: nothing to erase
2927 JSR plot_star ; Yes: plot it again to erase it
292A .erase_next_star←1← 2925 BEQ
DEY ; Next star down
292B BPL erase_stars ; Until stars 2 to 0 are done
292D RTS ; Return: a key is down and the stars are gone

Start a star at a free place

Take the first of the three stars not showing, if any, mark it in star_showing, give it frame 0 and step +1, choose a free place at random, mark the place taken and plot the first frame. Called by twinkle_stars about one pass in four. The random number is System VIA timer 1's low byte exclusive-ORed with &FA and &FC (the MOS's copy of A at the last interrupt), taking the low three bits; a place already taken is retried, which always ends because at most three of the eight places are taken.

On ExitAcorrupted
Xcorrupted
Ycorrupted
292E .start_star←1← 2911 JSR
LDY #0 ; Find a star not showing...
2930 .find_free_star←1← 2938 BNE
LDA star_showing,y ; ...star Y showing?
2933 BEQ star_found ; No: use this one
2935 INY ; Yes: try the next
2936 CPY #3 ; ...of the three
2938 BNE find_free_star ; Not all tried: carry on looking
293A RTS ; All three showing: return
293B .star_found←1← 2933 BEQ
LDA #1 ; Mark it showing
293D STA star_showing,y ; ...setting its star_showing flag to 1
2940 LDA #1 ; Frame step +1...
2942 STA star_frame_step,y ; ...the star starts by growing
2945 LDA #0 ; ...from frame 0
2947 STA star_frame,y ; ...the smallest, in star_frame
294A .pick_place←1← 2957 BMI
LDA system_via_t1c_l ; Pick a place at random (timer, &FA and &FC mixed)...
294D EOR os_zp_fa ; ...mixed with OS workspace...
294F EOR os_irq_a ; ...and the last interrupt's A...
2951 AND #7 ; ...one of the eight places
2953 TAX ; ...as the place index
2954 LDA star_places_x,x ; ...that no other star is using
2957 BMI pick_place ; Taken (&FF): pick again; three stars leave five free
2959 STA star_x,y ; The star's byte column, from the place...
295C LDA star_places_y,x ; ...its pixel row...
295F STA star_y,y ; ...as the star's row
2962 STX star_place,y ; ...remembering the place, to free it later
2964 LDA #&ff ; Mark the place taken
2966 STA star_places_x,x ; ...by setting its column to &FF
2969 JSR plot_star ; Plot the first frame
296C RTS ; Return with the new star on the screen

Advance each star by one frame

One frame of the twinkle, called by twinkle_stars on every pass. For each of the three stars in turn: if it is showing, erase its frame (plotting it again) and add its step to star_frame; past frame 6 it shows frame 5 and its step becomes -1, and below frame 0 it is finished, cleared in star_showing and its place freed in star_places_x; otherwise plot the new frame. Then pause: 5 x 255 loops after a star that is showing or has just finished, 20 x 255 for a star not showing. These pauses set the speed of the twinkle.

On ExitAcorrupted
Xcorrupted
Ycorrupted
296D .advance_stars←1← 2914 JSR
LDY #0 ; For each star...
296F .advance_star←1← 29B6 BNE
LDA star_showing,y ; ...is star Y showing?
2972 BEQ star_not_showing ; No: just pause, for longer
2974 JSR plot_star ; Erase its frame (plotting it again)
2977 CLC ; Step the frame
2978 LDA star_frame,y ; ...the star's current frame...
297B ADC star_frame_step,y ; ...plus the step, +1 or -1...
297E STA star_frame,y ; ...as the frame to show next
2981 BMI star_finished ; Shrunk below frame 0: the star has gone
2983 CMP #7 ; Grown past frame 6, the largest?
2985 BCC plot_new_frame ; No: plot it
2987 LDA #5 ; Yes: frame 5 instead...
2989 STA star_frame,y ; ...so frame 6 shows once at the peak...
298C LDA #&ff ; ...and from now on...
298E STA star_frame_step,y ; ...step -1, so the star shrinks
2991 BMI plot_new_frame ; ...and plot it (always branches)
2993 .star_finished←1← 2981 BMI
LDA #0 ; Gone: not showing...
2995 STA star_showing,y ; ...cleared in star_showing...
2998 LDA star_x,y ; ...and free its place
299B LDX star_place,y ; ...by putting its column back...
299D STA star_places_x,x ; ...over the &FF in star_places_x
29A0 BPL star_pause ; ...then pause (always branches: place 0-7)
29A2 .plot_new_frame←2← 2985 BCC← 2991 BMI
JSR plot_star ; Plot the new frame
29A5 .star_pause←1← 29A0 BPL
TYA ; Pause, setting the twinkle's speed...
29A6 PHA ; ...keeping Y, the star...
29A7 LDX #5 ; ...5 x 255 loops after a star is drawn
29A9 .star_pause_outer←2← 29AF BNE← 29D4 BNE
LDY #&ff ; ...X x 255 iterations...
29AB .star_pause_inner←1← 29AC BNE
DEY ; ...count the inner loop...
29AC BNE star_pause_inner ; Inner loop not done: keep waiting
29AE DEX ; ...count the outer loop...
29AF BNE star_pause_outer ; Outer loop not done: keep waiting
29B1 PLA ; ...recover the star...
29B2 TAY ; ...back into Y as the star index
29B3 INY ; Next star up
29B4 CPY #3 ; ...of the three
29B6 BNE advance_star ; More stars: advance the next
29B8 RTS ; Return with every star moved on a frame

Plot star Y's current frame

Call title_plot_star with the star's position (star_x, star_y) and frame (star_frame), keeping Y. Being an exclusive-OR, the same call both draws and erases a star: start_star, advance_stars and twinkle_stars use it for both.

On EntryYstar, 0-2
On ExitYpreserved
29B9 .plot_star←4← 2927 JSR← 2969 JSR← 2974 JSR← 29A2 JSR
LDA star_x,y ; plot_x = star's column
29BC STA plot_x ; ...the left edge of the frame
29BE LDA star_y,y ; plot_y = star's row
29C1 STA plot_y ; ...the top of the frame
29C3 LDA star_frame,y ; sprite_number = star's frame
29C6 STA sprite_number ; ...selecting one of the seven sizes
29C8 TYA ; Plot it, keeping Y
29C9 PHA ; ...on the stack
29CA JSR title_plot_star ; ...exclusive-OR the frame on screen
29CD PLA ; ...recover the star...
29CE TAY ; ...back into Y, as on entry
29CF RTS ; Return with the frame flipped and Y kept
29D0 .star_not_showing←1← 2972 BEQ
TYA ; Star not showing: pause for longer...
29D1 PHA ; ...keeping Y, the star...
29D2 LDX #&14 ; ...20 x 255 loops instead of 5 x 255
29D4 BNE star_pause_outer ; ...always taken: X = 20, into the pause loop
29D6 EQUB &38, &38, &3E, &3E ; Not used
; One flag per star, indexed by star 0-2: 1 while the star is ; showing, 0 when it is not. Cleared by twinkle_stars at the ; start (the bytes in the file are never read), set by ; start_star, cleared by advance_stars when a star shrinks away.
29DA .star_showing←6Used as index base by← 2904 STA← 2922 LDA← 2930 LDA← 293D STA← 296F LDA← 2995 STA
EQUB &38, &38, &3E ; Stars 0-2, cleared before use
29DD EQUB &3E, &38, &38 ; Not used
; The byte columns (0-79) of the eight places a star can appear, ; indexed by place 0-7. start_star copies a place's column to ; star_x and writes &FF there to mark the place taken; ; advance_stars writes the column back from star_x when the star ; has gone.
29E0 .star_places_x←3Used as index base by← 2954 LDA← 2966 STA← 299D STA
EQUB &2F, &20, &05, &00, &1F, &46, ; Places 0-7: byte &46, &14 ; columns
29E8 EQUB &00, &00, &00, &00, &00, &00, &00, &00 ; Not used
; The pixel rows of the eight places' top edges, indexed by ; place 0-7 and read by start_star into star_y.
29F0 .star_places_y←1Used as index base by← 295C LDA
EQUB &0F, &0F, &24, &42, &33, &0F, &48, ; Places 0-7: pixel &15 ; rows
29F8 EQUB &00, &00, &00, &00, &00, &00, &00, &00 ; Not used
fall through ↓

Star frames

Seven 7-byte by 28-row MODE 2 frames of the title screen's twinkling star, from small (frame 0) to large (frame 6).

; The seven frames of the star, 7 bytes by 28 rows each, at ; &C4-byte intervals.
2A00 .star_frame_data
EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; Fr &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; am &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; e &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; 0: &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; 7 &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; by &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; te &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; s &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, ; by &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, ; 28 &15, &1F, &00, &00, &00, &00, &00, &00, &2A, &00, ; ro &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, ; ws &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
2AC4 EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; Fr &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; am &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; e &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; 1: &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; 7 &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; by &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, ; te &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, ; s &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, ; by &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, ; 28 &2A, &0A, &2A, &00, &00, &00, &00, &00, &2A, &00, ; ro &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, ; ws &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &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
2B88 EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; Fr &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; am &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; e &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; 2: &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; 7 &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, ; by &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, ; te &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; s &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, ; by &00, &00, &00, &00, &2A, &00, &00, &00, &00, &15, ; 28 &2A, &00, &3F, &00, &00, &00, &00, &00, &2A, &00, ; ro &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, ; ws &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &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
2C4C EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; Fr &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; am &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; e &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, ; 3: &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; 7 &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, ; by &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; te &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, ; s &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, ; by &00, &00, &00, &00, &2A, &00, &00, &00, &00, &2A, ; 28 &2A, &00, &2A, &2A, &00, &00, &00, &00, &2A, &00, ; ro &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, ; ws &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &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
2D10 EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; Fr &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; am &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, ; e &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, ; 4: &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; 7 &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, ; by &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, ; te &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, ; s &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, ; by &00, &00, &00, &00, &2A, &00, &00, &00, &15, &15, ; 28 &2A, &00, &3F, &15, &00, &00, &00, &00, &2A, &00, ; ro &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, ; ws &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00
2DD4 EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; Fr &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, ; am &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; e &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, ; 5: &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, ; 7 &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, ; by &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, ; te &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, ; s &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, ; by &00, &00, &00, &00, &2A, &00, &00, &00, &2A, &2A, ; 28 &2A, &00, &2A, &2A, &2A, &00, &00, &00, &2A, &00, ; ro &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, ; ws &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00
2E98 EQUB &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; Fr &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, ; am &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; e &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, ; 6: &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, ; 7 &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, ; by &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, ; te &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, ; s &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, ; by &00, &00, &00, &00, &00, &00, &00, &00, &2A, &3F, ; 28 &2A, &00, &3F, &2A, &2A, &00, &00, &00, &00, &00, ; ro &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, ; ws &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00, &00, &00, &00, &2A, &00, &00, &00