[
  {
    "path": ".gitignore",
    "content": ".DS_Store\n\n"
  },
  {
    "path": "LICENSE",
    "content": "bootLogo - Small Logo language in a boot sector.\nCopyright (c) 2024 Oscar Toledo G. http://nanochess.org/\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "Makefile",
    "content": "# Makefile contributed by jtsiomb\n\nsrc = bootlogo.asm\n\n.PHONY: all\nall: bootlogo.img bootlogo.com\n\nbootlogo.img: $(src)\n\tnasm -f bin -o $@ $(src)\n\nbootlogo.com: $(src)\n\tnasm -f bin -o $@ -Dcom_file=1 $(src)\n\n.PHONY: clean\nclean:\n\t$(RM) bootlogo.img bootlogo.com\n\n.PHONY: rundosbox\nrundosbox: bootlogo.com\n\tdosbox $<\n\n.PHONY: runqemu\nrunqemu: bootlogo.img\n\tqemu-system-i386 -fda bootlogo.img\n"
  },
  {
    "path": "README.md",
    "content": "     _                 _   _\n    | |               | | | |\n    | |__   ___   ___ | |_| |     ___   __ _  ___\n    | '_ \\ / _ \\ / _ \\| __| |    / _ \\ / _` |/ _ \\\n    | |_) | (_) | (_) | |_| |___| (_) | (_| | (_) |\n    |_.__/ \\___/ \\___/ \\__\\_____/\\___/ \\__, |\\___/\n                                    __/ |\n                                   |___/\n### bootLogo interpreter in 512 bytes (boot sector or COM file)\n\n*by Oscar Toledo G. Mar/18/2024*\n\nhttp://nanochess.org\n\nhttps://github.com/nanochess\n\nThis is a small interpreter of Logo language.\n\nIt's compatible with the 8088 processor (the original IBM PC), and it even works on CGA mode!\n\nIf you want to assemble it, you must download the Netwide Assembler (NASM) from www.nasm.us\n\nUse this command line:\n\n    nasm -f bin bootlogo.asm -Dcom_file=1 -o bootlogo.com\n    nasm -f bin bootlogo.asm -Dcom_file=0 -o bootlogo.img\n\nTested with VirtualBox for macOS running Windows XP running this interpreter, it also works with DOSBox and probably with QEMU:\n\n    qemu-system-x86_64 -fda bootlogo.img\n\nYou can set also the following labels:\n\n* video_mode. This sets the video mode used for bootLogo (default = 4 for CGA mode 320x200x4 colors). A good alternative is 13 (EGA/VGA 320x200x16 mode).\n* color1. This sets the color for the letters in the command line (default = 1 for CGA mode)\n* color2. This sets the color for line drawing (default = 3 for CGA mode)\n\nEnjoy it!\n\n## User's manual\n\nLine entry is done with the keyboard, finish the line with Enter.\n\nBackspace can be used to correct mistakes.\n\nThe following commands are implemented:\n\n### CLEARSCREEN\n\nClears the screen and returns the turtle to the center, and pointing to the north. This command can only be used alone.\n\n### FD 40\n\nMove the turtle 40 pixels ahead. Caveat: If you use zero, it will be taken as 65536 pixels.\n\n### BK 40\n\nMove the turtle 40 pixels backward. Caveat: If you use zero, it will be taken as 65536 pixels.\n\n### RT 25\n\nRotate the turtle  25 degrees clockwise.\n\n### LT 25\n\nRotate the turtle 25 degrees counterclockwise.\n\n### REPEAT 10 FD 10\n\nRepeat 10 times FD 10\n\n### REPEAT 10 [FD 10 RT 20]\n\nRepeat 10 times FD 10 RT 20. REPEAT can be nested. If you somehow miss the final ] character then bootLogo will crash.\n\n### PU\n\nPen up. The turtle doesn't draw for following commands.\n\n### PD\n\nPen down. The turtle draws again.\n\n### SETCOLOR 2\n\nSet color for pen. Only 0-3 available in CGA, and 0-15 for EGA/VGA.\n\n### TO [name] [command or list of commands] END\n\nThis command allows you to define procedures. All the definition should fit inside one line (120 characters).\n\nA single command could be a REPEAT. Several commands can be grouped using [ and ].\n\nOnly the two first letters of the name are taken in account. The predefined commands have priority (so you cannot define them out). Also, once defined a procedure, it cannot be edited again (sorry, lack of space).\n\nFor example:\n\n    TO CURVE REPEAT 4 [LT 10 FD 10] END\n    TO PETAL [CURVE LT 140 CURVE] END\n    TO FLOWER REPEAT 4 [PETAL LT 50] END\n    FLOWER\n    RT 180\n    FD 50\n    RT 140\n    PETAL\n    PU\n    FD 50\n    \n### QUIT\n\nExit to command line (only .COM version)\n\n## Examples\n\n![bootLogo command sequence](example3.png)\n\n![Result of bootLogo command sequence](example4.png)\n\n## Acknowledgments\n\n* jcmeyrignac for an idea to make smaller the number decoding.\n* Jim Leonard (MobyGamer) for making me thinking about a higher-precision sin function, and suggesting me the use of the Set Pixel BIOS service.\n* raulamd for reminding me that cubicDoom had a smaller sin function.\n\n## More on this?\n\nDo you want to learn 8086/8088 assembler? Get my book Programming Boot Sector Games containing an 8086/8088 crash course!\n\nNow available from Lulu:\n\n[Paperback book](http://www.lulu.com/shop/oscar-toledo-gutierrez/programming-boot-sector-games/paperback/product-24188564.html)\n\n[Hard-cover book](http://www.lulu.com/shop/oscar-toledo-gutierrez/programming-boot-sector-games/hardcover/product-24188530.html)\n\n[eBook](https://nanochess.org/store.html)\n\nThese are some of the example programs documented profusely\nin the book:\n\n  * Guess the number.\n  * Tic-Tac-Toe game.\n  * Text graphics.\n  * Mandelbrot set.\n  * F-Bird game.\n  * Invaders game.\n  * Pillman game.\n  * Toledo Atomchess.\n  * bootBASIC language.\n"
  },
  {
    "path": "bootlogo.asm",
    "content": "        ;\r\n        ; bootLogo: A Logo implementation in a boot sector.\r\n        ;\r\n        ; by Oscar Toledo G.\r\n        ; https://nanochess.org/\r\n        ;\r\n        ; (c) Copyright 2024 Oscar Toledo G.\r\n        ;\r\n        ; Creation date: Mar/18/2024 5:40pm.\r\n        ; Revision date: Mar/18/2024 8:22pm. Working base commands.\r\n\t; Revision date: Mar/18/2024 10:13pm. Working REPEAT command.\r\n\t; Revision date: Mar/19/2024. Optimized number decoding. Optimized sin function\r\n\t;                             and now it has 7-bit precision. Used extra bytes\r\n\t;                             for PU/PD commands.\r\n        ;\r\n\r\n        cpu 8086\r\n\r\n\t;\r\n\t; bootLogo is an implementation of the basics of the Logo language.\r\n        ;\r\n\t; You have the following commands:\r\n        ;\r\n\t; CLEARSCREEN\t\tClears the screen (only can be used alone)\r\n\t; FD 40    \t\tMove the turtle 40 pixels ahead\r\n\t; BK 40    \t\tMove the turtle 40 pixels backward.\r\n\t; RT 25    \t\tRotate the turtle 25 degrees clockwise.\r\n\t; LT 25    \t\tRotate the turtle 25 degrees counterclockwise.\r\n\t; REPEAT 10 FD 10\tRepeat 10 times FD 10\r\n\t; REPEAT 10 [FD 10 RT 20]\tRepeat 10 times FD 10 RT 20.\r\n\t;\t\t\tRepeat can be nested.\r\n\t; PU                    Pen up (turtle doesn't draw).\r\n\t; PD                    Pen down (turtle draws).\r\n        ; SETCOLOR 1            Set color for pen.\n\t; TO name def END       Defines a procedure \"name\" with definition \"def\"\n\t;                       \"def\" can be any single command, or a list of\n\t;                       commands between [ and ].\n        ; QUIT                  Exit to command line (only .COM version)\r\n\t;\r\n\r\n    %ifndef com_file\r\ncom_file:       equ 0\r\n    %endif\r\n\r\n    %ifndef video_mode\r\nvideo_mode:     equ 4   ; CGA 320x200x4 colors.\r\n    %endif\r\n\r\n    %ifndef color1\r\ncolor1:         equ 1   ; Color for command line.\r\n    %endif\r\n\r\n    %ifndef color2\r\ncolor2:         equ 3   ; Color for drawing.\r\n    %endif\r\n\r\n    %if com_file\r\n        org 0x0100\r\n    %else\r\n        org 0x7c00\r\n    %endif\r\n\r\n\t;\r\n\t; Variables are saved just after the program.\r\n\t;\r\nANGLE:  equ $+0x0400\t; Current angle of the turtle.\r\nX_COOR: equ $+0x0402    ; Current fractional X-coordinate (9.7)\r\nY_COOR: equ $+0x0404    ; Current fractional Y-coordinate (9.7)\r\nPEN:\tequ $+0x0406    ; Current pen state.\r\nNEXT:\tequ $+0x0407\nPROCS:\tequ $+0x0409\t; Procedures.\r\n\r\nBUFFER: equ $+0x0300\t; Buffer for commands.\r\n\r\nFRACTION_BITS:  equ 7   ; How many bits has the fraction.\r\nUNIT:   equ 0x01<<FRACTION_BITS ; An unit.\n\nPROC_SIZE:\tequ 0x007e\t; Maximum size of a procedure.\r\n\r\n\t;\r\n\t; Cold start of bootLogo\r\n\t;\r\nstart:\r\n        push cs\t\t; Use the code segment...\r\n        push cs\r\n        pop ds\t\t; ...to initialize DS, and...\r\n        pop es\t\t; ...also ES.\n        cld\t\t; Clear direction flag.\r\n\tcall command_clearscreen\t; Clear the screen.\n\tmov ax,PROCS\t; Erase all procedures.\n\tstosw\t\t; Store word.\n\r\n\t;\r\n\t; Wait for command.\r\n\t;\r\nwait_for_command:\r\n        mov ax,wait_for_command\r\n        push ax\r\n\r\n        mov dl,0        ; Point to first column.\r\n        call set_cursor\t; CH is zero from here.\r\n        mov al,' '      ; ASCII space character in AL.\r\n        int 0x10        ; Call BIOS.\r\n\r\n        call xor_turtle\t; Show turtle (1st XOR)\r\n\r\n        mov di,BUFFER\t; Point to command buffer.\r\n\tpush di\r\n        mov al,'>'\t; Show prompt character.\ninput_loop:\r\n        mov dx,di\t; Get column.\n\tjmp input_loop3\r\n\ninput_loop2:\r\n        mov al,' '      ; Erase previous character with a space.\n\tmov dx,di\t; Point to previous character.\r\n\tdec di\t\t; Buffer pointer gets back.\r\ninput_loop3:\n        call set_cursor\t; CH is zero from here.\r\n        mov cl,1        ; One character.\r\n        int 0x10\t; Call BIOS.\r\n        mov ah,0x00\t; Wait for key function.\r\n        int 0x16\t; Call BIOS.\r\n\tcmp al,0x08\t; Backspace?\r\n\tjz input_loop2\t; Yes, jump.\r\n        cmp al,'a'\t; Is it lowercase?\r\n        jb .1\r\n        cmp al,'z'+1\r\n        jnb .1\t\t; No, jump.\r\n        sub al,0x20\t; Convert to uppercase.\r\n.1:\r\n        stosb\t\t; Save into buffer.\r\n        cmp al,0x0d\t; Is it Enter?\r\n        jne input_loop\t; No, jump to wait for more keys.\r\n\r\n        call xor_turtle\t; Remove turtle (2nd XOR)\r\n\r\n\tpop si\t\t; SI points to start of the command buffer.\r\n\n\t;\n\t; Run commands alone or in a list.\n\t;\nrun_commands:\r\n\tcall avoid_spaces\t; Avoid spaces.\r\n\tcmp al,'['\t\t; Is it a list of commands?\n\tjne run_command\t\t; No, jump to process a single command.\r\n        inc si                  ; Avoid list character '['.\r\n.1:\r\n\tcall run_command\t; Run a single command.\r\n\tcall avoid_spaces\t; Avoid spaces.\r\n\tcmp al,']'\t\t; Is it end of list?\r\n\tjne .1\t\t\t; No, keep reading commands.\r\n        inc si                  ; Avoid list character ']'.\r\n\tret\n\r\n\t;\r\n\t; Run a command.\r\n\t; SI = Pointer to current position in buffer.\r\n\t;\r\nrun_command:\r\n\tcall avoid_spaces\n\t;\n\t; Search for builtin commands.\n\t;\r\n        mov di,commands\t; DI points to command list.\n\tmov cx,11\t; Eleven commands.\r\n\tlodsw\t\t; Read command to execute.\n.1:\r\n        scasw           ; Compare with command from table.\r\n        jz found\t; Jump if same.\r\n\tscasb\t\t; Avoid command address.\n\tloop .1\r\n\n\t;\n\t; Search for defined procedures.\n\t; \n\tmov di,PROCS-PROC_SIZE\n.7:\tlea di,[di+PROC_SIZE]\t; Go to next procedure.\n\tcmp di,[NEXT]\t; End of defined procedures?\n\tje avoid_command\t; Yes, jump.\n\tscasw\t\t; Compare against procedure name.\n\tjnz .7\t\t; Jump if not the same.\n\tpush si\n\tmov si,di\t; Use definition as source pointer.\n\tcall run_commands\t; Run command or commands.\n\tpop si\n\n\t;\r\n\t; Avoid extra letters of command.\r\n\t;\r\navoid_command:\r\n\tlodsb\t\t; Read a character.\r\n\tsub al,0x41\t; Make 'A'-'Z' to be 0-25.\r\n\tcmp al,0x1a\t; Is it a letter?\r\n\tjb avoid_command\t; Yes, jump.\r\n\tdec si\t\t; Get back to the right point.\r\n\r\n\t;\r\n\t; Avoid spaces.\r\n\t;\r\navoid_spaces:\r\n\tlodsb\t\t; Read a character.\r\n\tcmp al,0x20\t; Is it space?\r\n\tje avoid_spaces\t; Yes, jump.\r\n\tdec si\t\t; Get back to the right point.\r\n\tret\r\n\r\n\t;\r\n\t; Command found.\r\n\t;\r\nfound:  call avoid_command\r\n        xor cx,cx\t; Set number to zero.\r\n.3:\r\n        lodsb\t\t; Get a character.\r\n        sub al,'0'\t; Is it a number?\r\n        cmp al,10\r\n        jnb .5\t\t; No, jump.\r\n        cbw\t\t; Extend digit 0-9 in AL to AX.\r\n\tpush ax\t\t; AH guaranteed to be zero.\r\n        mov al,10\t; CX = CX * 10 + digit\r\n        mul cx\r\n\tpop cx\r\n        add cx,ax\r\n        jmp short .3\t; Keep reading number.\r\n.5:\n\tdec si\n\t\t\t; >>> This depends on all commands and command table located \n\t\t\t;     inside the same 256-byte page <<<\n\tpush di\n\tpop ax\t\t; To get high byte of address.\n\tadd al,[di]\t; Get location (low byte).\n\n\tjmp ax\n\n\t;\n\t; Set cursor position.\n\t; DL = column (0-255).\n\t;\r\nset_cursor:\n\tmov cx,40\t; 40 columns.\n.1:\n\tsub dl,cl\t; Limit column to range 0-39.\n\tjnb .1\n\tadd dl,cl\n\n\tmov dh,21\t; Row 21 of the screen.\r\n        mov bx,color1   ; Page (bh) and color (bl).\r\n        mov ah,0x02     ; Set video row, column function.\r\n        int 0x10\t; Call BIOS.\r\n\tmov ah,0x09\r\n        ret\r\n\r\n\t;\r\n\t; Limit the angle to 0-359 and then to the size of the sin table.\r\n\t;\r\nlimit:\r\n\tmov bx,360\t; 360 degrees is the limit.\r\n\r\n        cwd\t\t; Sign extend AX to DX:AX\r\n\tidiv bx\t\t; Limit it to 360 degrees...\r\n\tor dx,dx\t; ...by getting modulo.\r\n\tjns .1\r\n\tadd dx,bx\t; Make modulo positive.\r\n.1:\r\n        mov ax,128\t; Multiply by sin table length.\r\n        mul dx\r\n        div bx\t\t; Divide by 360 degrees.\r\n                        ; Now AX is between 0 and 127.\r\n                        ; (this means AH is zero)\r\n        ;\r\n        ; Get sine\r\n        ;\r\n        test al,64      ; Angle >= 180 degrees?\r\n        pushf\r\n        test al,32      ; Angle 90-179 or 270-359 degrees?\r\n        je .2\r\n        xor al,31       ; Invert bits (reduces table)\r\n.2:\r\n        and al,31       ; Only 90 degrees in table\r\n        mov bx,sin_table\r\n        xlat            ; Get fraction\r\n        popf\r\n        je .3           ; Jump if angle less than 180\r\n        neg ax          ; Else negate result\r\n.3:\r\n        ret\t\t; Return.\r\n\r\n\t;\r\n\t; XOR turtle against the background.\r\n\t;\r\nxor_turtle:\r\n        push word [X_COOR]\t; Save X-coordinate.\r\n        push word [Y_COOR]\t; Save Y-coordinate.\r\n        mov cl,5  \t\t; 5 pixels (depends on CH being zero).\n\txor ax,ax\r\n.1:\tcall advance\t\t; Advance to get turtle nose.\r\n        loop .1\t\t\t; Until reaching 5 pixels.\r\n\t\t\t\t; ch guaranteed to be zero here.\n\tmov si,turtle_angles\t; Table to draw the turtle.\n\tlodsb\t\t\t; Get angle for this line.\n\n.2:\tmov cl,5\n\tmul cl\r\n.3:\n\tmov bx,0x0080\t\t; XOR pixel.\n\tcall draw_pixel2\t; Draw in X,Y coordinates.\r\n        loop .3\t\t\t; Loop to draw the line.\n\tlodsb\t\t\t; Get angle for next line.\n\ttest al,al\t\t; Is it zero?\n\tjnz .2\r\n.4:\n        pop word [Y_COOR]\t; Restore Y-coordinate.\r\n        pop word [X_COOR]\t; Restore X-coordinate.\r\n        ret\t\t\t; Return.\r\n\ncommands:\r\n\tdb \"CL\"\r\n\tdb command_clearscreen-$\r\n        db \"FD\"\r\n        db command_fd-$\r\n        db \"BK\"\r\n        db command_bk-$\r\n        db \"RT\"\r\n        db command_rt-$\r\n        db \"LT\"\r\n        db command_lt-$\r\n\tdb \"RE\"\r\n\tdb command_repeat-$\r\n\tdb \"PU\"\r\n\tdb command_pu-$\r\n\tdb \"PD\"\r\n\tdb command_pd-$\r\n\tdb \"SE\"\r\n\tdb command_setcolor-$\n\tdb \"TO\"\n\tdb command_to-$\n        db \"QU\"\r\n        db command_quit-$\r\n\n\t;\n\t; CLEARSCREEN command\n\t;\ncommand_clearscreen:\n        mov ax,video_mode\r\n        int 0x10\t; Set video mode.\r\n\r\n        mov di,ANGLE\t; Point to ANGLE variable.\r\n        xor ax,ax\t; Zero (north)\r\n        stosw\t\t; Store word.\r\n        mov ah,UNIT*160/256     ; Initial X-coordinate.\r\n        stosw\t\t; Store word.\r\n        mov ah,UNIT*100/256     ; Initial Y-coordinate.\r\n        stosw\t\t; Store word.\r\n\tinc ax\t\t; Pen down.\r\n\tstosb\t\t; Store byte.\r\n\tret\n\nrepeat_loop:\r\n        pop si\t\t\t; Restore start position to re-parse.\r\n\t;\r\n\t; REPEAT command\r\n\t;\r\ncommand_repeat:\r\n        push si                 ; Save position in buffer.\r\n        push cx                 ; Save repeat count.\n\tcall run_commands\r\n        pop cx                  ; Restore count.\r\n        loop repeat_loop\r\n        pop di                  ; Ignore start position, keep advanced position.\r\n\tret\r\n\n\t;\n\t; TO command\n\t;\ncommand_to:\n\tmov di,[NEXT]\t\t; Pointer to space for next procedure.\n\tmovsw\t\t\t; Copy procedure name (only 2 letters)\n\tcall avoid_command\t; Avoid extra letters.\n\tmov cx,PROC_SIZE\n\trep movsb\t\t; Copy procedure body.\n\tmov [NEXT],di\t\t; Update pointer.\n\tret\n\n\t;\r\n\t; BK command.\r\n\t;\r\ncommand_bk:\r\n        mov ax,-180\t; Reverse direction (-180 degrees)\r\n        db 0xba         ; mov dx, to jump following instruction.\r\n\t;\r\n\t; FD command.\r\n\t;\r\ncommand_fd:\r\n        xor ax,ax\t; Normal direction.\r\n\t;\r\n\t; Set pixel.\r\n\t; \r\npixel_set:\r\n\tcall draw_pixel\t; Draw in X,Y coordinates.\r\n        loop pixel_set\r\n        ret\r\n\r\n\t;\r\n\t; LT command.\r\n\t;\r\ncommand_lt:\r\n\tneg cx\t\t; Negate angle.\r\n\t;\r\n\t; RT command.\r\n\t;\r\ncommand_rt:\r\n        add [ANGLE],cx\t; Rotate turtle clockwise.\r\n        ret\t\t; Return.\r\n\r\n\t;\r\n\t; PU command\r\n\t;\r\ncommand_pu:\r\n\tmov al,0\t; Pen up.\r\n\tdb 0xba\t\t; MOV DX to jump over following instruction\r\n\r\n\t;\r\n\t; PD command\r\n\t;\r\ncommand_pd:\r\n\tmov al,1\t; Pen down.\r\n\tmov [PEN],al\t; Set pen status.\r\n\tret\t\t; Return.\r\n\r\n\t;\r\n\t; SETCOLOR command\r\n\t;\r\ncommand_setcolor:\r\n\tmov [COLOR],cl\t; Save new pen color.\r\n\tret\t\t; Return.\r\n\r\n\t;\r\n\t; QU command.\r\n\t;\r\ncommand_quit:\r\n        int 0x20\t; Exit to DOS or bootOS.\r\n\r\n\t;\r\n        ; Draw pixel in current X,Y integer coordinates.\r\n\t;\r\ndraw_pixel:\n\ttest byte [PEN],0x01\r\n\tjz draw_pixel3\n\txor bx,bx\t; Set pixel.\ndraw_pixel2:\r\n\tpush ax\n\tpush cx\r\n        mov cl,FRACTION_BITS\r\n        mov ax,[X_COOR] ; Get X-coordinate.\r\n        shr ax,cl       ; Remove fractional part.\r\n        mov dx,[Y_COOR] ; Get Y-coordinate.\r\n        shr dx,cl       ; Remove fractional part.\r\n        xchg ax,cx\n\nCOLOR:\tequ $+1\t\t; Self-modifying code.\r\n\tmov ax,0x0c00+color2\t; Color for pen plus Set Pixel function code.\r\n\n\tor al,bl\t; ...plus mode (SET or XOR).\r\n\tint 0x10\n\tpop cx\n\tpop ax\ndraw_pixel3:\r\n\t;\r\n\t; Advance turtle in direction.\n\t; ax = Offset in degrees for angle.\r\n\t;\r\nadvance:\n\tpush ax\n\tadd ax,[ANGLE]\t; Add current angle to offset in ax.\r\n        push ax\r\n        call limit\t; Limit angle and get sin.\r\n        add [X_COOR],ax\t; Add to X-coordinate.\r\n        pop ax\r\n        add ax,90\t; For getting cos.\r\n        call limit\r\n        sub [Y_COOR],ax\t; Subtract to Y-coordinate.\n\tpop ax\n        ret\r\n\n\t;\n\t; Shape for the turtle.\n\t; It draws 5 pixels in each of the following relative angles.\n\t;\r\nturtle_angles:\n\tdb 210/5\n\tdb 210/5\n\tdb 70/5\n\tdb 110/5\n\tdb 330/5\n\tdb 330/5\n\t;\n\t; Table ending marked by a zero byte taken from the start of sin_table.\n\t;\n\r\n\t;\r\n        ; sin() function table\r\n        ; It must follow FRACTION_BITS.\r\n\t;\r\nsin_table:\r\n\tdb 0x00, 0x06, 0x0d, 0x13, 0x19, 0x1f, 0x25, 0x2b\r\n\tdb 0x31, 0x37, 0x3c, 0x42, 0x47, 0x4c, 0x51, 0x56\r\n\tdb 0x5b, 0x5f, 0x63, 0x67, 0x6a, 0x6e, 0x71, 0x74\r\n\tdb 0x76, 0x79, 0x7a, 0x7c, 0x7e, 0x7f, 0x7f, 0x80\r\n\r\n    %if com_file\r\n    %else\r\n        times 510-($-$$) db 0xff\r\n        db 0x55,0xaa    ; Make it a bootable sector\r\n    %endif\r\n\r\n\r\n"
  },
  {
    "path": "e.bat",
    "content": "nasm -f bin bootlogo.asm -l bootlogo.lst -o bootlogo.img\r\nnasm -f bin bootlogo.asm -Dcom_file=1 -o bootlogo.com\r\n\r\n"
  }
]