scene.org File Archive

File download

<root>­/­parties­/­2023­/­vccc23­/­christmas-diamonds/viri_jupiterace_forth_vc3-2023.zip

File size:
23 857 390 bytes (22.75M)
File date:
2024-01-03 14:15:18
Download count:
all-time: 3

Preview

  • viri_jupiterace_forth_vc3-2023/ dir
  • viri_jupiterace_forth_vc3-2023/20231224_1.jpg 321.72K
  • viri_jupiterace_forth_vc3-2023/20231224_2.jpg 347.06K
  • viri_jupiterace_forth_vc3-2023/challenge.mp4 444.50K
  • viri_jupiterace_forth_vc3-2023/challenge.tap 117B
  • viri_jupiterace_forth_vc3-2023/code.txt 121B
  • viri_jupiterace_forth_vc3-2023/explanation_for_prg_length.jpg 91.19K
  • viri_jupiterace_forth_vc3-2023/file_id.diz 2.90K
  • viri_jupiterace_forth_vc3-2023/on_a_real_hardware.mp4 21.61M
  • viri_jupiterace_forth_vc3-2023/prg_listing.jpg 70.66K

file_id.diz

<Ace Stars>
Author: <viri>
Category: <Christmas Challenge>
System:   <Jupiter Ace>
Language: <Forth>
Len source code: <75 bytes> (i.e. The Jupiter Ace compiles the word definitions when typing in, so the source code and the executable code's size is the same. FYI the size of the challenge.tap file is 117 bytes)
Len exe file:    <no such thing in Ace>
Len code only:   <75 bytes> (i.e. total length of the word in memory that can be executed and which displays the object on screen)
Instructions:
<The code was tried and tested on a real hardware and in the xAce emulator under Linux. The easiest way to reproduce the code is typing it in within an emulator from the code.txt file. Please type it in as it is written, all the spaces are important! Then you can run the word "c" by just typing c (and ENTER). If you choose to use the challenge.tap file instead, then (under xAce) do the followings: attach the tape image by hitting F3, then switch to the terminal window of the xAce and enter the name of the tape (challenge.tap). Now switch back to the emulator window and type LOAD c (and ENTER). Then you can run the code by typing c (and ENTER).
Probably the challenge.tap file works in other emulators too, but I don't have Windows, so I haven't tested it.>
Description:
<The algorithm I wrote is super simple and it exploits the fact that the entire object is drawn in a 19x19 rectangle, and from the first star character (from the top-left one) every sixth position contains a new star character. This way if we put a star in every sixth position (starting from the 4th position on the top row), and staying within the 19x19 rectangle, then we'll have HALF of the object drawn, that is we'll have all 6 lines in this direction: //////. To draw the remaining half part we just simply mirror all the points horizontally, so we get the \\\\\\ lines as well.  
Note: In Forth terminology a "command" is called "word". So the word I wrote does the followings: it iterates from 3 to 360 stepping by 6, and it uses this loop counter to calculate the X1 and Y coordinates at which a star character will be printed. The Y coordinate (row) is simply calculated by an integer division by 19. The X1 (column) coordinate is calculated by a modulo 19 division. This ensures that the stars stay within the first 19 position. An X2 coordinate is also calculated by subtracting X1 from 18 - this way we mirror all X1 coordinates horizontally. Then we use the built-in AT word to print the star character to the (X1,Y) and (X2,Y) positions. That's it.
Although the object is fully drawn at the loop counter value of 351, but if we stop there, then the OK message from the operating system would show up within the object, hence I let the iteration run until 361.>
Comments:
<My code is certainly not amongst the smallest ones, but I thoroughly enjoyed tinkering with this challenge, and I'm looking forward to the next one as well! Thanks and Happy Holidays!>