Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
User Journal

Journal clone53421's Journal: Real Men...

...don't need C to write a Valentine's day card (nor a redundant microcontroller when they already have all the computing power they need in their desktop PC).

(Copy, paste into Notepad, save as untitled.bat, double-click to launch.)

Note to Vista users: Vista dropped support for full-screen DOS graphics modes, but the .com executable will still run in DOSBox. (If you copy debug.exe into your DOSBox C folder, the batch file will run in DOSBox – otherwise you'll have to run the batch in Vista and run the .com with DOSBox.)

@echo off
goto batch
 
a
;Generates random numbers using an Additive Lagged Fibonacci Generator, j=7, k=10.
;The system timer (clock ticks since midnight) is used to seed a LCG to generate initial values
;Random values are masked using top[col] <= row < bottom[col]
        call 01d0 ;_seed
        mov ax,0012
        int 10 ;Set video mode 12 (640x480x16 graphics)
        mov bx,0284 ;_pal
        mov dx,03c8
        xor al,al
        out dx,al
        mov dx,03c9
        xor cl,cl
;_setpal
        mov al,cl
        xlat
        out dx,al
        inc cl
        cmp cl,12
        jne 012c ;_tst1
        mov dx,03c8
        mov al,14
        out dx,al
        mov dx,03c9
        jmp 0116 ;_setpal
;_tst1
        cmp cl,15
        jne 013c ;_tst2
        mov dx,03c8
        mov al,07
        out dx,al
        mov dx,03c9
        jmp 0116 ;_setpal
;_tst2
        cmp cl,18
        jne 014c ;_tst3
        mov dx,03c8
        mov al,38
        out dx,al
        mov dx,03c9
        jmp 0116 ;_setpal
;_tst3
        cmp cl,30
        jne 0116 ;_setpal
        mov di,02b6 ;_top
        mov si,07b6 ;_bottom
;_loop
        call 01a0 ;_rand
        mov bx,0005
        xor dx,dx
        div bx
        shl ax,1
        mov bx,0029
        xor dx,dx
        div bx
        mov cx,ax ;CX holds the column number
        call 01a0 ;_rand
        mov bx,000c
        xor dx,dx
        div bx
        mov bx,0005
        mul bx
        mov bx,0039
        xor dx,dx
        div bx
        xchg ax,dx ;DX holds the row number
        mov ah,0c
        and al,0f
        call 020a ;_plot
        call 0243 ;_glow
;Check for keypress (non-blocking call) to exit
        mov ah,06
        mov dl,ff
        int 21
        jz 0157 ;_loop
        mov ax,0002
        int 10 ;Set video mode 2 (25x80x16 text)
        mov ax,4c01
        int 21 ;return to DOS
;Return the next random number in AX.
;_rand
        xor bh,bh
        mov bl,[01f5+14] ;_lastValues
        mov ax,[bx+01f5] ;_lastValues
        add bx,06
        cmp bx,14
        jl 01b5 ;_next1rand
        sub bx,14
;_next1rand
        add ax,[bx+01f5] ;_lastValues
;Store the new random number (AX) in the last values history
        mov bl,[01f5+14] ;_lastValues
        mov [bx+01f5],ax ;_lastValues
;Increment our pointer to the oldest last value
        inc bx
        inc bx
        cmp bx,14
        jl 01cb ;_next2rand
        sub bx,14
;_next2rand
        mov [01f5+14],bl ;_lastValues
        ret
;Seed the random number generator using the system timer
;_seed
        xor ah,ah
        int 1a ;Get ticks since midnight in CX:DX
        mov [01f5],dx ;_lastValues
        mov ax,dx
        xor bx,bx
;_LCG
        mov dx,4e35
        mul dx
        inc ax
        inc bx
        inc bx
        mov [bx+01f5],ax ;_lastValues
        cmp bx,12
        jl 01dc ;_LCG
        or ax,0001 ;LFG needs at least 1 odd initial value
        mov [bx+01f5],ax ;_lastValues
        ret
;_lastValues
dw 0,0,0,0,0,0,0,0,0,0
db 0
;Plot the pixel if it's within the masked area
;_plot
        mov bp,ax
        mov bx,cx
        shl bx,1
        mov ax,[di+bx]
        cmp ax,dx
        ja 0223 ;_noplot
        mov ax,[si+bx]
        cmp ax,dx
        jbe 0223 ;_noplot
        mov ax,bp
        xor bh,bh
        int 10 ;plot the pixel
        ret
;_noplot
;adjust out-of-range values so we'll end up plotting them somewhere
;this makes a cool ring effect by adjusting the colour :)
        mov ax,bp
        mov bx,13f
        sub bx,cx
        sar bx,1
        sar bx,1
        sar bx,1
        add cx,bx ;move toward the centre (horizontally)
        mov bx,ef
        sub bx,dx
        sar bx,1
        sar bx,1
        sar bx,1
        add dx,bx ;move toward the centre (vertically)
        or al,8 ;tweak the colour (brighter / whiter)
        jmp 020a ;_plot
;_glow
        call 01a0 ;_rand
        cmp ax,6000
        jge 024c ;_glow0
        ret
;_glow0
        mov ax,[02b4] ;_count
        mov cx,ax
        inc ax
        mov [02b4],ax ;_count
        shr ah,1
        shr ch,1
        cmp ah,ch
        jnz 025e ;_glow1
        ret
;_glow1
        cmp ah,40
        jbe 026d ;_glow2
        mov bh,ah
        mov ah,80
        sub ah,bh
        jns 026d ;_glow2
        neg ah
;_glow2
        cmp ah,40
        jne 0273 ;_glow3
        ret
;_glow3
        mov dx,03c8
        xor al,al
        out dx,al
        mov dx,03c9
        mov al,ah
        out dx,al
        xor al,al
        out dx,al
        out dx,al
        ret
;_pal
db 0,0,0,7,0,0,f,0,0,17,0,0,1f,0,0,27,0,0,2f,0,0,37,0,0,3f,0,0
db 3f,9,9,3f,12,12,3f,1b,1b,3f,24,24,3f,2d,2d,3f,36,36,3f,3f,3f
;_count
dw 0
;_top
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,90,88,82,7e
dw 7b,76,74,72,6f,6c,6a,68,65,63,62,60,5e,5c,5b,59
dw 57,56,55,54,53,51,50,4e,4d,4c,4b,4a,49,48,47,45
dw 44,43,42,41,40,3f,3e,3e,3d,3c,3b,3a,3a,39,38,37
dw 36,35,35,34,33,33,33,32,31,31,30,2f,2f,2e,2e,2d
dw 2d,2c,2b,2b,2b,2b,2a,29,29,28,28,27,27,27,26,26
dw 25,25,25,24,24,24,23,23,23,22,22,22,22,21,21,21
dw 21,20,20,20,20,1f,1f,1f,1f,1f,1e,1e,1e,1e,1d,1d
dw 1d,1d,1d,1d,1d,1d,1d,1c,1c,1c,1c,1c,1c,1c,1c,1c
dw 1c,1c,1c,1c,1c,1c,1c,1c,1b,1b,1b,1b,1b,1b,1b,1b
dw 1b,1b,1b,1b,1b,1c,1c,1c,1c,1c,1c,1c,1c,1c,1c,1c
dw 1c,1c,1c,1c,1d,1d,1d,1d,1d,1d,1d,1d,1e,1e,1e,1e
dw 1e,1e,1e,1f,1f,1f,20,20,20,20,20,20,21,21,21,22
dw 22,22,22,23,23,23,23,24,24,24,25,25,25,26,26,26
dw 26,27,27,27,28,28,29,29,29,2a,2a,2a,2b,2b,2c,2c
dw 2d,2d,2e,2e,2f,2f,30,30,31,32,32,33,33,33,34,35
dw 35,36,37,37,38,39,39,3a,3b,3c,3c,3d,3e,3f,40,41
dw 41,40,3f,3e,3d,3c,3c,3b,3a,39,39,38,37,37,36,35
dw 35,34,33,33,33,32,32,31,30,30,2f,2f,2e,2e,2d,2d
dw 2c,2c,2b,2b,2a,2a,2a,29,29,29,28,28,27,27,27,26
dw 26,26,26,25,25,25,24,24,24,23,23,23,23,22,22,22
dw 22,21,21,21,20,20,20,20,20,20,1f,1f,1f,1e,1e,1e
dw 1e,1e,1e,1e,1d,1d,1d,1d,1d,1d,1d,1d,1c,1c,1c,1c
dw 1c,1c,1c,1c,1c,1c,1c,1c,1c,1c,1c,1b,1b,1b,1b,1b
dw 1b,1b,1b,1b,1b,1b,1b,1b,1c,1c,1c,1c,1c,1c,1c,1c
dw 1c,1c,1c,1c,1c,1c,1c,1c,1c,1d,1d,1d,1d,1d,1d,1d
dw 1d,1d,1e,1e,1e,1e,1f,1f,1f,1f,1f,20,20,20,20,21
dw 21,21,21,22,22,22,22,23,23,23,24,24,24,25,25,25
dw 26,26,27,27,27,28,28,29,29,2a,2b,2b,2b,2b,2c,2d
dw 2d,2e,2e,2f,2f,30,31,31,32,33,33,33,34,35,35,36
dw 37,38,39,3a,3a,3b,3c,3d,3e,3e,3f,40,41,42,43,44
dw 45,47,48,49,4a,4b,4c,4d,4e,50,51,53,54,55,56,57
dw 59,5b,5c,5e,60,62,63,65,68,6a,6c,6f,72,74,76,7b
dw 7e,82,88,90,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;_bottom
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,b0,b7,bc,c1
dw c7,ca,cd,cf,d4,d7,d9,dd,df,e2,e4,e6,e9,eb,ed,ee
dw f0,f3,f5,f7,f8,fb,fd,fe,ff,101,103,105,106,108,109,10a
dw 10c,10e,10f,111,113,114,115,117,118,119,11b,11c,11d,11e,120,121
dw 123,124,125,126,127,128,129,12a,12c,12d,12e,12f,130,131,132,133
dw 135,136,137,138,139,13a,13b,13c,13d,13e,13f,140,141,142,143,144
dw 145,146,147,148,149,14a,14b,14c,14c,14d,14e,14f,150,151,152,153
dw 154,154,155,156,157,158,159,159,15a,15b,15c,15d,15d,15e,15e,15f
dw 160,161,162,162,163,164,165,166,166,167,168,169,169,16a,16b,16b
dw 16c,16d,16e,16f,16f,170,171,171,172,173,173,174,174,175,176,176
dw 177,178,178,179,17a,17a,17b,17c,17c,17d,17e,17e,17f,180,180,180
dw 181,182,182,183,183,184,185,185,186,187,187,188,188,189,18a,18a
dw 18a,18b,18c,18d,18d,18d,18e,18e,18f,190,191,191,191,192,193,193
dw 194,194,195,195,196,196,197,198,198,198,199,19a,19a,19b,19c,19c
dw 19c,19d,19e,19e,19f,19f,1a0,1a0,1a1,1a1,1a2,1a2,1a3,1a4,1a4,1a5
dw 1a5,1a6,1a6,1a7,1a8,1a8,1a9,1aa,1aa,1ab,1ab,1ac,1ac,1ad,1ae,1af
dw 1af,1b0,1b1,1b1,1b2,1b3,1b4,1b5,1b6,1b8,1b9,1ba,1bb,1bc,1bc,1bc
dw 1bc,1bc,1bc,1bb,1ba,1b9,1b8,1b6,1b5,1b4,1b3,1b2,1b1,1b1,1b0,1af
dw 1af,1ae,1ad,1ac,1ac,1ab,1ab,1aa,1aa,1a9,1a8,1a8,1a7,1a6,1a6,1a5
dw 1a5,1a4,1a4,1a3,1a2,1a2,1a1,1a1,1a0,1a0,19f,19f,19e,19e,19d,19c
dw 19c,19c,19b,19a,19a,199,198,198,198,197,196,196,195,195,194,194
dw 193,193,192,191,191,191,190,18f,18e,18e,18d,18d,18d,18c,18b,18a
dw 18a,18a,189,188,188,187,187,186,185,185,184,183,183,182,182,181
dw 180,180,180,17f,17e,17e,17d,17c,17c,17b,17a,17a,179,178,178,177
dw 176,176,175,174,174,173,173,172,171,171,170,16f,16f,16e,16d,16c
dw 16b,16b,16a,169,169,168,167,166,166,165,164,163,162,162,161,160
dw 15f,15e,15e,15d,15d,15c,15b,15a,159,159,158,157,156,155,154,154
dw 153,152,151,150,14f,14e,14d,14c,14c,14b,14a,149,148,147,146,145
dw 144,143,142,141,140,13f,13e,13d,13c,13b,13a,139,138,137,136,135
dw 133,132,131,130,12f,12e,12d,12c,12a,129,128,127,126,125,124,123
dw 121,120,11e,11d,11c,11b,119,118,117,115,114,113,111,10f,10e,10c
dw 10a,109,108,106,105,103,101,ff,fe,fd,fb,f8,f7,f5,f3,f0
dw ee,ed,eb,e9,e6,e4,e2,df,dd,d9,d7,d4,cf,cd,ca,c7
dw c1,bc,b7,b0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;_ASCIIZ
                db "untitled.com",0
;_compile
                MOV AX,CS
                MOV DS,AX
                MOV AH,3c
                XOR CX,CX
                MOV DX,0cb6 ;_ASCIIZ
                INT 21
                MOV BX,AX
                MOV CX,0cb6 ;_ASCIIZ
                MOV DX,0100 ;where the program starts
                SUB CX,DX
                MOV AH,40
                INT 21
                MOV AH,3e
                INT 21
                MOV AX,4c01
                INT 21
 
r ip
cc3
g
q
 
:batch
if exist untitled.com goto run
 
if exist %0 goto extension
debug < %0.bat
goto run
 
:extension
debug < %0
 
:run
untitled.com

This discussion has been archived. No new comments can be posted.

Real Men...

Comments Filter:

Get hold of portable property. -- Charles Dickens, "Great Expectations"

Working...