scene.org File Archive

File download

<root>­/­parties­/­2022­/­vccc22­/­christmas_star_challenge/juliem_bbc_6502_vc3-2022.zip

File size:
47 345 bytes (46.24K)
File date:
2022-12-30 11:32:13
Download count:
all-time: 4

Preview

  • juliem_bbc_6502_vc3-2022/ dir
  • juliem_bbc_6502_vc3-2022/file_id.diz 3.68K
  • juliem_bbc_6502_vc3-2022/juliem_bbc_6502_vc3-2022.ssd 5.00K
  • juliem_bbc_6502_vc3-2022/listing.png 27.77K
  • juliem_bbc_6502_vc3-2022/output.png 10.00K
  • juliem_bbc_6502_vc3-2022/star_source.md 6.46K
  • juliem_bbc_6502_vc3-2022/STARSRC.BAS 3.22K

file_id.diz

juliem_bbc_6502_vc3-2022.zip
----------------------------

List of files:
    file_id.diz                     - this file
    juliem_bbc_6502_vc3-2022.ssd    - BBC micro disc image
    listing.png                     - image of (partial) source listing
    output.png                      - image of output
    star_source.md                  - annotated assembler source
    STARSRC.BAS                     - BBC Micro BASIC / assembler source
                                        (detokenised, readable on host)

Author: Julie Kirsty Louise Montoya <bluerizlagirl@gmail.com>
Category: Christmas Challenge
System:   BBC Micro
Language: BBC BASIC / 6502 Assembler (built-in BASIC assembler)
Len source code: 2977 bytes  (tokenised on target system)
                 3302 bytes  (detokenised on host system)
Len exe file:    71 bytes
Len code only:   71 bytes

Instructions:

Install BeebEm or another suitable BBC emulator, if you have not already ;)
Start emulator. NB: Make sure Econet is disabled!
Load the disc image "juliem_bbc_6502_vc3-2022.ssd" in drive 0
Make sure the disc is NOT write-protected
Enter the following command to assemble the machine code:
*EXEC !MAKE
Press SHIFT to scroll the screen when it becomes full.
There will now be a new file on the disc called STAR
Type the following to run the assembled code:
*STAR


Description:

STARSRC is a BASIC program which uses the BBC Micro's built-in assembler
to assemble a 6502 machine code program, which draws a star identical to
the pattern given in the programming challenge, as near to the centre of
the screen as possible.

!MAKE is a *EXEC script file which loads and runs STARSRC.

The program relies on a table of lengths of groups of spaces and stars
alternately.  Due to the strict alternation, we only need to specify the
length of each group, and not whether it is spaces or stars.  The table
ends at the point where should come a group of 9 stars which form the
middle row of the star pattern.

First we initialise the screen to MODE 7 and print four "cursor down"
control characters, to centre the image vertically.  This sequence is
stored in memory in reverse order, so we can use Y as a pointer into it,
end up with Y=0 and be ready to reuse Y as a pointer into the table
of lengths.  We initialise A with &20 to print a group of spaces.

For each entry in the table, we load the length into X; then we print
X copies of A to the screen, decreasing X each time.  After printing the
last character of the group, we EOR A with &0A, to toggle between spaces
and stars, and increase Y to get the next entry in the table.

At the end of the table, having printed a group of 30 spaces and being
ready to print stars, we change  (using the X register, so as not to
mess up the contents of A or Y)  the INY instruction which was previously
used to step forwards through the table to a DEY; load X with 9 for the
length of the middle row of stars; and jump back to the drawing loop.

After this, Y will be *de*creased, now pointing to the 30 again; and so we
will begin working backwards through the table, printing groups of spaces
and stars alternately until Y becomes equal to zero.  At this point, the
cursor will somewhere on the right hand side of the screen; so we JMP to
an operating system entry point to start a new line, and rely on its own
RTS to return to the BASIC prompt.

Comments:

Having already been a little bit naughty with self-modifying code, I saw
an opportunity to save a little bit more space by placing the whole thing
in zero page and using short addresses.  Unfortunately, this means it
stomps on some workspace used by the Acorn Econet hardware; so if your
emulator was built with Econet support, you should make sure it is turned
off before running the code.