============================================================================= h u g i s i z e c o d i n g c o m p e t i t i o n g e n e r a l i n f o ============================================================================= ---------------------------------- [RULES] ---------------------------------- Unless stated otherwise in the competition specific rules, your entry must ... follow the competition specific rules. ... have the filename "entry.com". ... work in a Windows95 DOS box. ... work on the Adok's PC. an Intel Pentium 600, 64 MByte RAM, running Windows 98 [Version 4.10.2222]. ... use only instructions up to i586 (Pentium). Unless stated otherwise, your entry must NOT ... depend on its file name, i.e. it still has to work after renaming it to, say, FOOBAR.EXE, or any other valid DOS executable file name. ... depend on its drive or path. ... crash unless where explicitly stated by the rules. ... use MMX instructions or other non-Pentium instructions like CMOVcc; look at the "x86.txt" file for further information. ... use the special registers CR0..4 (this includes the MSW), DR0..7, or RDMSR/WRMSR instructions. ... use any external files or create new files on the disk. ... rely on any previously loaded code or data in memory, excluding DOS itself. ... disable interrupts for longer than 1/50 second in a row on a 200MHz Pentium. ... have been modified by means of an executable-packer (i.e., entry.com must be the product of assembling entry.asm). You may assume that ... the registers have these values (all in hex): (xx - means an unknown value which MUST NOT be assumed) EAX = xxxx**** AL = 00 if first FCB has valid drive letter, FF if not AH = 00 if second FCB has valid drive letter, FF if not EBX = xxxx0000 ECX = xxxx00FF EDX = xxxxxxxx DX = CS = DS = ES = SS = xxxx, 0080 <= DX <=9000. ESI = xxxx0100 EDI = xxxxFFFE EBP = xxxx09xx ESP = xxxxFFFE EIP = xxxx0100 EFLAGS (binary) = xxxxxxxx xxxxxxxx xxxx0x1x xx0x0x1x i.e. DF = 0 IF = 1 other flags = x WORD [FFFE] = 0000 Layout of PSP: see [Memory Layout] ... that the program is not loaded high. ... that DPMI services are available. ... FCB functions can be used to access files whose name is given in 8.3 format. You must NOT assume that ... the FPU state is defined; you have to use FINIT to initialize it before using it. If you use other's people code (from previous compos or the like), please add a comment about this to your code, including a reference to the original program. Oh yes, and please comment your code. ------------------------------ [MEMORY LAYOUT] ------------------------------ The PSP is a copy of a buffer containing the history of command line arguments. You can assume that all preceding command line arguments were smaller than 100 bytes. That is: PSP:[E5h] = 0Dh or 0 PSP:[E6h]...[FFh] = 0 Format of Program Segment Prefix (PSP) (located at initial DS:0000): [according to Ralf Brown's Interrupt List] Offset Size Description (Table 01378) 00h 2 BYTEs INT 20 instruction for CP/M CALL 0 program termination the CDh 20h here is often used as a signature for a valid PSP 02h WORD segment of first byte beyond memory allocated to program note: do not assume that this word contains 0A000h 04h BYTE (DOS) unused filler 05h BYTE CP/M CALL 5 service request (FAR CALL to absolute 000C0h) 06h WORD CP/M compatibility--size of first segment for .COM files 08h 2 BYTEs remainder of FAR JMP at 05h 0Ah DWORD stored INT 22 termination address 0Eh DWORD stored INT 23 control-Break handler address 12h DWORD DOS 1.1+ stored INT 24 critical error handler address 16h WORD segment of parent PSP 18h 20 BYTEs DOS 2+ Job File Table, one byte per file handle, FFh = closed 2Ch WORD DOS 2+ segment of environment for process (see #01379) 2Eh DWORD DOS 2+ process's SS:SP on entry to last INT 21 call 32h WORD DOS 3+ number of entries in JFT (default 20) 34h DWORD DOS 3+ pointer to JFT (default PSP:0018h) 38h DWORD DOS 3+ pointer to previous PSP (default FFFFFFFFh in 3.x) 3Ch BYTE DOS 4+ (DBCS) interim console flag (see AX=6301h) 3Dh BYTE (APPEND) TrueName flag (see INT 2F/AX=B711h) 3Eh 2 BYTE ? 40h 2 BYTEs DOS 5+ version to return on INT 21/AH=30h 42h 7 BYTE ? 49h BYTE unused by DOS versions <= 6.00 4Ch WORD ? 4Eh 2 BYTEs unused by DOS versions <= 6.00 50h 3 BYTEs DOS 2+ service request (INT 21/RETF instructions) 53h 2 BYTEs unused in DOS versions <= 6.00 55h 7 BYTEs unused in DOS versions <= 6.00; can be used to make first FCB into an extended FCB 5Ch 16 BYTEs first default FCB, filled in from first commandline argument overwrites second FCB if opened 6Ch 16 BYTEs second default FCB, filled in from second commandline argument overwrites beginning of commandline if opened 7Ch 4 BYTEs unused 80h 128 BYTEs commandline / default DTA command tail is BYTE for length of tail, N BYTEs for the tail, followed by a BYTE containing 0Dh -------------------------------- [CHECKING] --------------------------------- Usually, there is a test suite provided with the competition rules, which is irregularily updated; new versions can be found at http://www.hugi.de/compo/ However, the test suites usually only serve as a GUIDE, so please check your program against the rules before submitting. Also be aware that the test suite itself may contain bugs; if you find one, please send an e-mail about it to Adok (cdvolko@gmx.net) or (preferred) to the compo mailinglist (see below). ------------------------------- [SUBMISSION] -------------------------------- You have to send - the sourcecode of your entry - the executable of your entry ("entry.com") to Adok so that he can analyse and evaluate your entry. Send your entries to: cdvolko@gmx.net It would be best if you could submit your entry as early as possible. Then Adok can inform you about bugs, if he finds any, and you have enough time to fix them. Attention: if he finds no bugs, this doesn't automatically mean that your entry is bug-free; see also CHECKING (above). You can submit updates to your entries all the time till the deadline. Entries that do not agree with these rules will be disqualified. Their coders will be informed about the mistake, and they can re-submit a bugfixed version unless the compo is over. Only one entry per coder can qualify; if two or more coders work together on a single entry, it will count as a joint entry for those coders; no other entries of these coders can qualify. Note that the entry will count as a entry of this group of coders for the world league table. ----------------------------- [PUBLIC JUDGEMENT] ---------------------------- After the deadline for entry submission, as soon as the entries and the beta results are released, the public judgement starts. During this week you can discuss and object to the entries that seem to break some rule. Please send your objections to the compo-mailinglist (see below). Adok and/or a jury formed by him will check if your objections are according to the rules. If a hidden flaw is found in one of the originally accepted entries during the public judgement period, public judgement will decide what to do with the entry. Possible consequences include disqualification and penalties. ------------------------------- [PRE-RESULTS] ------------------------------- Preliminary results of this compo will be released on the compo-web-site and always updated after receiving a new entry. In this way the compo will hopefully be exciting. Compo-web-site URL: http://hugi.de/compo/ ---------------------------------- [PRIZES] --------------------------------- I'm sorry if I disappoint you, but there are no material prizes. Everything is just a matter of fun, honor and fame. Moreover, the 30 best competitors will get points and be listed in the 'World League Table of Assembly' situated at the compo-web-site. Reaching a good place at a compo and even more in the World League Table of Assembly is a good visiting-card and recommendation for every competitor! ------------------------------ [MAILING LIST] ------------------------------- The purpose of the Hugi Compo mailing list is to inform about new compos and provide a discussion forum for the competitors. At the moment there are about 220 subscribers. To subscribe send a mail to hugi-compo-subscribe@yahoogroups.com. You'll get an automatically generated mail which confirms your subscription within a few hours. Then you start getting the mails the others have posted to this mailinglist. You will have to subscribe to write mails to the mailinglist. Mails for the list have to be sent to: hugi-compo@yahoogroups.com If you want to subscribe, send a mail to: hugi-compo-subscribe@yahoogroups.com If you want to unsubscribe, send a mail to: hugi-compo-unsubscribe@yahoogroups.com The mailing list archive can be found at http://www.egoups.com/groups/hugi-compo/ -------------------------------- [ADDRESSES] -------------------------------- Send your entries to: cdvolko@gmx.net [Adok/Hugi] Compo-homepage (pre-results, world league table, test suites etc.): http://hugi.de/compo/ Subscribe to the mailing list: hugi-compo-subscribe@yahoogroups.com Unsubscribe from mailing list: hugi-compo-unsubscribe@yahoogroups.com Mailing list archive: http://www.yahoogroups.com/groups/hugi-compo/ ----------------------------------------------------------------------------- Thanks for reading this file! Original rules by Adok Extended and revised by INT-E ..............................................k....k......................l.......l......l.....l.......j...j..j..j...j..j...j....j.......j..............k.....k..........k.......k.........l...l...l..l....l...l...l........................................ ...............................j.....j.................j....... .....l.....l..j.....................k.......... .....j..j..j.j..........................k.......k.............k.....k.........k.............................k..j...j...j....j...j.......k....k..........k.......j........k...k........k.......l.....k......... ...................................j....k.........j....j.......k.....k......l...l...l...l...k....l....l.... .......k............k.....k......k...k...k...k..k.......l....l....l...l.............j...j...j.............................l...l...l..... .....................................k..............l..........................k.................................................................................................. .l........l..........k........k......k.....k....k....k......j...j....k....j.......l....... ....................k...........k.....l.....l.......l...l............ .....................k....j........j.j.j.jj.j. ....................................k.....k.....k...j...j.................................... .....................k........................l.........................j..... ........................k....j...j..j..j.....j........l.... .............................k...k....k...l................................................l............ ...................k.......j......l...l.....l.........l...................................................................... ..........................k...k.....k...............l... ..............................k...k....k..l.............l... ...........................k......k....k...j..j...j......... .............................k...k.....k.............k...j........j.jj.j.j. ................................................................l.....j...........l.. .......................................................k...k..j........j.j.j.jj. ...............k...j.......k.................j............ ...........................................k...l....l.......... .........................k.....j........j.j.jj..........l....... .................k.....j.....j...j..j...... ...............................k.....................l................ ............................................k...k.......l......l..... .....................................l.....k........... .................k.....j...j..j...j....... ......................k....k....k...l..l........ ................k...j...j..j....j.... ................k......l....... .............k...j..j...j.......j..... .........k......k.............j............. ............................................k........k.......j...... ........................k....................k........k............ .................k...........k.......j....j.... ...................k....j...j.j..j..j... ........................k..........k....k..l...l..l...l... ...............................................k.....l... ............k................j..j..j..j.j..... ..................... ...........................k..............k...k.....l...l..l..l.. ..................k....k....k..................k.......k...l..l...l.. ....................................... ...................k.....j..j.... ......................k...l........l.l.l.l. .......................................................k...l...l...l............ ............................................k...k...k...j...j......... ......................k.......j......j..j..j....j...........l.....l........l.......l... .................j...j.... ..............................k.........................j........j.j.jj.j. ...................k..............k..........j........j.j.j.j. ............................l......l..... ...........................l..........k...........j........j.j.j.jj. .............k.............. ............................................l........l........ ..................................k.......... ....................j.....k......l...... ...........k.....l.... ..............k......... .............k........... .........................k......... ................... _ _| | _ _ _ _ _ _ _ |_ | | | _ _ _ _ _|_ _ _ _| | |_ | |_|_ _|_ _|_ | _| |_ | | _| | _| | | _|_ | _| | | | | | | | | | _ _ |_| | | | | | | | |_| |_ _| |_| |_| |_| | _| | |_|_| |_|_| |_ _|_ _| |_ _|_ _| |_ _| s i z e c o d i n g c o m p o _ _ _ _ _ _ _ _ _| _|_ |_ _| _|_ |_ |_ _| _|_ _| |_ _| _|_ _| _| _| _| _| _ _|_ _| _ _|_ _| | |_ _ _ _ | |_ _ _ _ |_ _|_ _ _ _| |_ _|_ _ _ _| Ladies and Gentlemen: The task this time will be something very retro, something from the good ol' days, something to show your grandchildren. And they already know it, most likely from their Game Boys. You all know what I'm talking about, but we dare not whisper the name, for the Tetris (tm) Company has not granted us the right. The Russian programmer Alexey Pajitnov invented this game of falling tetrominoes in 1984. Tetrominoes, of course, are the shapes determined by combinations of four adjacent squares. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |_|_| _|_|_| |_|_|_| |_|_|_ |_|_|_|_| |_|_|_| |_|_|_| |_|_| |_|_| |_| |_|_| |_| |_| In the game these shapes fall down the screen to the bottom where they are stacked. Keyboard commands manipulate them into (hopefully) nice neat horizontal rows. Each completed row with no free square in it dissolves, and any tetrominoes above it fall to fill in the missing row. So, the challenge of our competition is to make this game in the smallest piece of code that conforms to all the following picky little rules plus the rules in GENERAL.TXT. _ _ _ _ _ _ _ _ _| The screen |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ To make the game attractive 256-color 320x200 graphics are used (i.e: mode 13h). The squares in a tetromino are drawn as 3D tiles with beveled edges. The tiles are 8x8 pixels overall, with a one-pixel wide edge that is highlighted on one side and shaded on the other. There is no space between tiles in a tetromino. °°°°°°°°°°°°°°²² °°±±±±±±±±±±±±²² highlighted -->°°±±±±±±±±±±±±²² edge °°±±±±±±±±±±±±²² °°±±±±±±±±±±±±²² °°±±±±±±±±±±±±²² °°±±±±±±±±±±±±²²<-- shaded edge ²²²²²²²²²²²²²²²² <--- 6 ----> <----- 8 ------> The tiles are colored depending on the tetromino they are in. The default color palette is used. The palette registers are assigned to the center of the tile, the highlighted edge and the shaded edge as follows: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |_|_| _|_|_| |_|_|_| |_|_|_ |_|_|_|_| |_|_|_| |_|_|_| |_|_| |_|_| |_| |_|_| |_| |_| blue purple violet pink red orange yellow center: 32 34 36 38 40 42 44 hilite: 80 82 84 86 88 90 92 shadow: 104 106 108 110 112 114 116 The tetrominoes fall down a 'well' represented by a 10x23 tile field plus a one-tile border along its sides and bottom. Border tiles have these colors: center: 52 _ _ _ _ _ _ _ _ _ _ _ _ hilite: 100 |_|_|_|_|_|_|_|_|_|_|_|_| shadow: 124 cyan The well is centered on the screen. Centered above the well is the score. Four digits are always displayed with leading zeros. The BIOS font is used with normal white (7) characters on a black (0) background. The entire screen is black except where the score or a tile appear. 0000 ^ þ þ ^ | þ þ | | þ þ | | þ þ | | þ þ 23 25 lines = tiles þ þ | | þ þ | | þ þ | | þ þ v | þþþþþþþþþþþþ v <-- 10 --> <--- 12 ---> tiles A correctly laid out well will have the upper-left corner of its upper- left border tile at coordinate 112,8 (0,0 is the upper-left corner of the screen). The lower-right pixel in the lower-right corner of the well will be at 207,199. _ _ _ _ _ _ _ _| Game play |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ The game starts by initializing the score to 0000. One of the seven tetrominoes is randomly selected and released at the top of the well. It falls at a speed determined by the DOS system clock and the score. While the tetromino is falling, it can be manipulated with these keystrokes: 'j' - shift left 'l' - shift right 'k' - rotate space - drop at full speed Within the confines of the well (or previously played tetrominoes) the falling tetromino can be shifted left or right one tile width (8 pixels) for each keystroke. The falling tetromino also can be rotated 90 degrees counterclockwise per keystroke. The center of rotation (+) for each tetromino is shown here: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |_|_| _|+|_| |_|+|_| |_|+|_ |_|_|+|_| |_|+|_| |_|+|_| |_|_| |_|_| |_| |_|_| |_| |_| The first tetromino, the blue block, rotates about its center rather than one of its tiles. The highlighted and shaded edges on tiles, of course, don't rotate. Tetrominoes are always confined to the inside of the well. A tetromino cannot be rotated if any part of it would appear above the top of the well. In effect there is an invisible barrier across the top of the well. Tetrominoes are started at the top center of the well in the orientations (rotations) shown above. The tetrominoes that are three tiles wide can't be centered perfectly and are started with their centers of rotation (+) offset to the right, or in the 6th empty column of the well. If the tetromino cannot be placed at its starting position without overlapping a previously played tetromino then the game is over. Besides the keys used to manipulate the tetrominoes, these keystrokes are also used: Esc - terminates the program at any time space - starts the next game Any other (undefined) keystrokes must be ignored; they must not do anything. (Exceptions are system keystrokes such as Alt+Enter or Pause.) Interrupt 16h function 0 must be used to read a keystroke; and function 1 must be used to detect if a keystroke is pending. This is required by the test suite, which hooks this interrupt vector. _ _ _ _ _ _ _| Scoring |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Points are scored by the height from which tetrominoes are dropped and the number of completed rows that are collapsed by a single tetromino. For each vertical tile position that a tetromino drops at full speed, one point is awarded. (In other words, a point is given for each 8 pixels that a piece falls after the spacebar is hit.) Completed rows are awarded points on an increasing scale. It's possible to collapse as many as four rows at once by dropping the long red piece into a slot. Collapsing a single row is worth 20 points. Rows Points 1 20 2 60 3 140 4 300 _ _ _ _ _ _ _| Timing |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ The speed of the game is regulated by the DOS system clock. Your entry must use interrupt 1Ah function 0 to access the tick count. This is necessary so that the test suite can stay synchronized. The rate that tetrominoes initially fall is (10 - score/256) / 18.2 seconds. In other words, when the score is less than 256, the tetromino falls one tile position (8 pixels) for every 10 ticks. When the spacebar is hit, the drop rate increases to one tile position per tick. Completed rows collapse at the same rate as the initial falling speed. If the initial speed is one tile per 5 ticks then rows will collapse once per 5 ticks. You may assume that there is always at least one tick, or in other words, that the score will never reach 2560. _ _ _ _ _ _ _ _ _| Randomness |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ The random numbers used to select the sequence of falling tetrominoes must be generated by the following algorithm. Again this is required so that the test suite can stay synchronized. This algorithm is short and sweet, and is from "Master Class Assembly Language" by Wrox Press, page 840. mov ax, seed ;seed:= seed*9421 + 1 mul n9421 inc ax mov seed, ax mov dx, 0 ;randomNum:= remainder(seed/7) div n7 ;dx (the remainder) contains a random number from 0..6 ;The initial value of the 'seed' is set when the program first starts seed dw 12345 n9421 dw 9421 n7 dw 7 _ _ _ _ _ _| Steps |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Here are the steps that must be done. The order that keystrokes (in step 4) and waiting for timer ticks (in steps 5 and 7) must be followed so that your entry will pass the test suite. 1: Set graphic mode 13h. Set score to 0000 (and display it). Set up empty well with tile borders on sides and bottom. 2: Randomly select one of seven tetrominoes. If it won't fit at the top of the well then go to 8. Display tetromino at top of well. Set speed_of_fall (in system clock ticks) to 10 - score/256. 3: Set timer to speed_of_fall. 4: If a keystroke is not waiting to be read in then skip to 5. Get keystroke (BIOS interrupt 16h). If key is Esc then go to 9. If key is 'j' then see if tetromino can be shifted one tile position left. If key is 'l' then see if it can be shifted one tile position right. If key is 'k' then see if it can be rotated counterclockwise 90 degrees. If there are no tiles in the way then erase tetromino from its present position and draw it in its new position. 5: Wait for a tick (BIOS interrupt 1Ah). Decrement timer. If spacebar was not hit and timer has not expired (not = 0) then go to 4. See if tetromino can shift down one tile position. If there are tiles already in this new position then go to 6. Erase tetromino from its present position. Draw tetromino in its new position. If the spacebar was pressed then increment the score (and display it). Go to 3. 6: Set 'points' to 20. 7: If there is no horizontal row full of tiles then go to 2. Remove row and move all tiles above it down one row. Add 'points' to score (and display result). Double 'points'. Wait for speed_of_fall number of ticks to elapse. Go to 7. 8: Get keystroke. If key is space (if spacebar was struck) then go to 1. If key is Esc then go to 9. Go to 8. 9: Restore mode 3 (80x25 text). Return to DOS (or Windows). _ _ _ _ _ _ _ _ _| Submitting |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Your entry file must be named "ENTRY.COM". Before submitting your entry make sure it passes the test suite by running TEST.BAT. Send your ENTRY.COM file along with its source code to this address: ------->> fys@cybertrails.com <<------- You may submit updates to your entries any time until the deadline. _ _ _ _ _ _ _ _| Schedule |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2003-May-16: Compo 22 starts 2003-Jul-26 23:59:59 MST: Submission deadline 2003-Jul-27: Sourcepack will be released; public judgment starts 2003-Aug-02: End of public judgment; final results will be released _ _ _ _ _ _ _| Creditz |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Thanks goes to claw for writing the first draft of these rules and getting this compo started. Boreal wrote the example program and revised the rules to match. And of course a big THANKS goes to Sniper for testing all the entries and posting the scores. Have fun! Especially while testing. ;-) TESTER.TXT 20-MAY-2003 Run TEST.BAT to test your ENTRY.COM for validity. This executes TESTER KEYS.TXT). It also sends a dot (.) for each timer tick if there was no keystroke. Because of a sync problem (that I'm too lazy to chase down right now) KEYS.TXT must be edited to delete one "." before the space character used to start the next game. Unfortunately TESTER.COM does not run properly under Windows. Two versions were tried: 98 and 3.1. Apparently Windows is also calling interrupts 16h and/or 1Ah. Even restarting in MS-DOS mode under Windows is not sufficient to make the tester work. You must boot directly into PURE DOS. It might even be a good idea to boot into safe mode. The tester works fine on three different computers running DOS 5 and 7. (Perhaps some of you geniuses can fix the problem. I hate Windoze!) There is at least one thing that the tester does not check for. It's possible that when a tetromino starts, it immediately completes the top row and clears it. It requires extra code in an entry to properly handle this extremely unlikely situation. In the interest of sacrificing Ruud's left foot, I'm inclined to not penalize entries that do not make sure that the top row has been erased from the screen. -Boreal